Beispiel #1
0
        public EventTaskList UpdateEventTaskList(EventTaskList taskList)
        {
            var existingTaskList = db.EventTaskLists.FirstOrDefault(p => p.Id == taskList.Id);

            if (existingTaskList != null)
            {
                existingTaskList.Name              = taskList.Name;
                existingTaskList.CrewId            = taskList.CrewId;
                existingTaskList.ServiceTemplateId = taskList.ServiceTemplateId;
                existingTaskList.PropertyServiceId = taskList.PropertyServiceId;
                existingTaskList.NumberServices    = taskList.NumberServices;
            }
            else
            {
                db.EventTaskLists.Add(taskList);
            }

            db.SaveChanges();

            return(taskList);
        }
Beispiel #2
0
 public static TTarget MapTo <TTarget>(this EventTaskList source) where TTarget : EventTaskListViewModel
 {
     return(Mapper.Map <EventTaskList, TTarget>(source));
 }
Beispiel #3
0
        public IEnumerable <EventDetails> GetEventSchedules(int year, int month, int date, int crewid)
        {
            try
            {
                //int crewid = 3;
                DateTime            selectedDate = new DateTime(year, month, date);
                DateTime            from         = GetFirstDayOfWeek(selectedDate, null);
                List <EventDetails> eventDetails = new List <EventDetails>();

                var service        = new EventService();
                var eventSchedules = service.GetEventsForCrewForDay(from, crewid);

                foreach (var eventVal in eventSchedules)
                {
                    EventTaskList propTask = db.EventTaskLists.Include("Crew").Include("Property").Include("EventTaskTimes").Single(pt => pt.Id == eventVal.EventTaskListId);
                    if (propTask.Crew == null)
                    {
                        continue;
                    }
                    Crew crewVal = propTask.Crew;
                    if (crewVal == null)
                    {
                        continue;
                    }

                    if (!string.IsNullOrEmpty(eventVal.RecurrenceRule))
                    {
                        var pattern   = new RecurrencePattern(eventVal.RecurrenceRule);
                        var evaluator = new RecurrencePatternEvaluator(pattern);
                        var items     = evaluator.Evaluate(new CalDateTime(eventVal.StartTime), eventVal.StartTime,
                                                           eventVal.StartTime.AddYears(5), false);
                        if (!items.Any(i => i.StartTime.Date == selectedDate))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (eventVal.StartTime.AddDays(-1) > selectedDate || eventVal.EndTime < selectedDate)
                        {
                            continue;
                        }
                    }

                    EventDetails eventDetail = new EventDetails();

                    TimeZoneInfo estZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

                    eventDetail.EventId             = eventVal.Id;
                    eventDetail.StartTime           = TimeZoneInfo.ConvertTimeFromUtc(eventVal.StartTime, estZone);
                    eventDetail.EndTime             = TimeZoneInfo.ConvertTimeFromUtc(eventVal.EndTime, estZone);
                    eventDetail.ActualEndTime       = eventVal.ActualEndTime;
                    eventDetail.ActualStartTime     = eventVal.ActualStartTime;
                    eventDetail.IsAllDay            = eventVal.IsAllDay;
                    eventDetail.RecurrenceRule      = eventVal.RecurrenceRule;
                    eventDetail.RecurrenceID        = eventVal.RecurrenceID;
                    eventDetail.RecurrenceException = eventVal.RecurrenceException;
                    eventDetail.StartTimezone       = eventVal.StartTimezone;
                    eventDetail.EndTimezone         = eventVal.EndTimezone;
                    eventDetail.Status          = (StatusEnum)eventVal.Status;
                    eventDetail.Title           = eventVal.Title;
                    eventVal.EventTaskList      = propTask;
                    eventDetail.TaskId          = propTask.Id;
                    eventDetail.EventTaskListId = eventVal.EventTaskListId;
                    eventDetail.PropertyId      = propTask.Property.Id;
                    eventDetail.PropertyAddress = propTask.Property.Address1 + " " +
                                                  propTask.Property.Address2 + " " +
                                                  propTask.Property.City.Name + " " +
                                                  propTask.Property.State + " " +
                                                  propTask.Property.Zip;

                    eventDetail.PropertyName      = eventVal.EventTaskList.Property.Name;
                    eventDetail.PropertyRefNumber = eventVal.EventTaskList.Property.PropertyRefNumber;
                    var eventTaskTime = propTask.EventTaskTimes.FirstOrDefault(e => e.EventDate.Subtract(selectedDate) == TimeSpan.Zero);
                    if (eventTaskTime != null)
                    {
                        eventDetail.TaskStartTime = eventTaskTime.StartTime;
                        eventDetail.TaskEndTime   = eventTaskTime.EndTime;
                    }
                    eventDetails.Add(eventDetail);
                }


                return(eventDetails.OrderBy(e => e.StartTime));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public EventTaskList GetEventTaskList(int id)
        {
            EventTaskList eventTaskList = db.EventTaskLists.Include("PropertyTasks").Include("Crew").FirstOrDefault(p => p.Id == id);

            return(eventTaskList);
        }