예제 #1
0
 public static Schedule Convert(this DbSchedule schedule)
 {
     return(new Schedule()
     {
         Id = schedule.ScheduleId, Number = schedule.Number ?? -1, Date = schedule.Date ?? DateTime.Now
     });
 }
예제 #2
0
        public int AddSchedule(int number, DateTime date)
        {
            var item = Context.Schedules.FirstOrDefault(x => x.Number == number && x.Date == date);

            if (item != null)
            {
                return(item.ScheduleId);
            }
            item = new DbSchedule()
            {
                Number = number, Date = date
            };

            Context.Schedules.Add(item);

            try
            {
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Exception:{ex.Message}");
                return(-1);
            }
            return(item.ScheduleId);
        }