Skip to content

Instantly share code, notes, and snippets.

@prabakaranr
Last active December 9, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prabakaranr/540734698ba4343b45286c5eaa996b35 to your computer and use it in GitHub Desktop.
Save prabakaranr/540734698ba4343b45286c5eaa996b35 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
Author

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