Skip to content

Instantly share code, notes, and snippets.

@prabakaranr

prabakaranr/Meeting.cs Secret

Last active Dec 9, 2019
Embed
What would you like to do?
public class Meeting
{
private string _subject;
public string Subject
{
get => _subject;
set
{
if (value == _subject) return;
_subject = value;
switch (_subject)
{
case "General Meeting":
Color = Xamarin.Forms.Color.FromHex("#7BC667");
break;
case "Release Retrospective":
Color = Xamarin.Forms.Color.FromHex("#9466F2");
break;
case "Sprint Meeting":
Color = Xamarin.Forms.Color.FromHex("#37AA97");
break;
default:
Color = Xamarin.Forms.Color.FromHex("#4C3AB9");
break;
}
}
}
public string Location { get; set; }
public Xamarin.Forms.Color Color { get; set; } = Xamarin.Forms.Color.FromHex("#7BC667");
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public Meeting(string subject, string location, DateTime startTime)
{
Subject = subject;
Location = location;
StartTime = startTime;
EndTime = StartTime.AddHours(1);
}
}
@JogyBlack

This comment has been minimized.

Copy link

@JogyBlack JogyBlack commented Dec 7, 2019

The code to set EndTime fails when StartTime.Hour is equal to 23 (11PM) : "System.ArgumentOutOfRangeException: 'Hour, Minute, and Second parameters describe an un-representable DateTime.'"

It is safer to use EndTime = StartTime.AddHours(1);

@prabakaranr

This comment has been minimized.

Copy link
Owner Author

@prabakaranr prabakaranr commented Dec 9, 2019

Thank you for notifying @JogyBlack. I have changed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment