Exemple #1
0
        public void DeleteCalendarEvent(CalendarEventDTO dto)
        {
            try
            {
                log.Debug(CalendarEventDTO.FormatCalendarEventDTO(dto));

                R_CalendarEvent t = CalendarEventDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteCalendarEvent(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemple #2
0
        public ActionResult Delete(int id, User u)
        {
            Web.ViewModel.UserCreateViewModel uc = new Web.ViewModel.UserCreateViewModel();
            uc.user = _UserRepository.GetUserById(id);

            if (uc.user.AssignedRoleId == 3)
            {
                // if its a SA , then delete the number of available SA from the timeslot table .

                var timeslots = _timeSlotRepository.TimeSlots;        // get the timeslots

                Threshold threshold = new Threshold();
                threshold = _ThresholdRepository.Thresholds.First();

                foreach (var timeslot in timeslots)
                {
                    timeslot.Num_Available_SA = timeslot.Num_Available_SA - 1;
                    timeslot.Title            = timeslot.Num_Available_SA;
                    if (timeslot.Num_Available_SA > threshold.Upper_Calendar)
                    {
                        timeslot.Color = "green";
                    }
                    else if (timeslot.Num_Available_SA >= threshold.Lower_Calendar && timeslot.Num_Available_SA <= threshold.Upper_Calendar)
                    {
                        timeslot.Color = "yellow";
                    }
                    else
                    {
                        timeslot.Color = "red";
                    }
                    _timeSlotRepository.SaveTimeSlot(timeslot);
                }

                // whenever a SA is deleted , the calendar events of the SA should also be deleted .

                IEnumerable <CalendarEvent> events = new List <CalendarEvent>();
                events = _eventsRepository.GetEventsByUserId(id);

                foreach (var e in events)
                {
                    _eventsRepository.DeleteCalendarEvent(e);
                }
            }

            _UserRepository.DeleteUser(id);

            return(View("Deleted"));
        }
Exemple #3
0
        public ActionResult deleteEvent(FormCollection eventToBeDeleted)
        {
            CalendarEvent events = new CalendarEvent();

            events.id = Int32.Parse(eventToBeDeleted[0]);
            _eventsRepository.DeleteCalendarEvent(events);



            string z1;

            string starttemp = eventToBeDeleted[14].Remove(0, 4);

            starttemp = starttemp.Remove(20);
            string endtemp = eventToBeDeleted[15].Remove(0, 4);

            endtemp = endtemp.Remove(20);
            DateTime tempstart = DateTime.Parse(starttemp);

            events.start = tempstart.ToString("yyyy-MM-ddTHH':'mm':'ss");
            DateTime tempend = DateTime.Parse(endtemp);

            events.end = tempend.ToString("yyyy-MM-ddTHH':'mm':'ss");


            Threshold threshold = new Threshold();

            threshold = _ThresholdRepository.Thresholds.First();

            var taskList = new List <CalendarDTO>();
            IEnumerable <TimeSlot> timeslots = new List <TimeSlot>();

            timeslots = _timeSlotRepository.TimeSlots;



            z1 = events.start;
            foreach (var timeslot in timeslots)
            {
                if (string.Compare(z1, timeslot.StartTime) == 0)
                {
                    timeslot.Num_Available_SA = timeslot.Num_Available_SA + 1;
                    timeslot.Title            = timeslot.Num_Available_SA;

                    if (timeslot.Num_Available_SA > threshold.Upper_Calendar)
                    {
                        timeslot.Color = "green";
                    }
                    if (timeslot.Num_Available_SA >= threshold.Lower_Calendar && timeslot.Num_Available_SA <= threshold.Upper_Calendar)
                    {
                        timeslot.Color = "yellow";
                    }
                    if (timeslot.Num_Available_SA == 0)
                    {
                        timeslot.Color = "red";
                    }
                    _timeSlotRepository.SaveTimeSlot(timeslot);
                }
            }
            return(null);
        }