public async Task SaveCalendar(CalendarDTO calendarDTO) { var calendar = await _unitOfWork.CalendarRepository.GetByIdAsync(calendarDTO.Id); calendar.StartDate = calendarDTO.StartDate; calendar.EndDate = calendarDTO.EndDate; calendar.WorkOnWeekend = calendarDTO.WorkOnWeekend; calendar.SeveralTaskPerDay = calendarDTO.SeveralTasksPerDay; calendar.ExtraDayOffs.Clear(); calendar.ExtraWorkDays.Clear(); calendar.ExtraDayOffs = calendarDTO.ExtraDayOffs.Select(x => new ExtraDay { Day = x.Day, DayOff = x.DayOff }).ToList(); calendar.ExtraWorkDays = calendarDTO.ExtraWorkDays.Select(x => new ExtraDay { Day = x.Day, DayOff = x.DayOff }).ToList(); _unitOfWork.CalendarRepository.Update(calendar); await _unitOfWork.SaveAsync(); }
public async Task OnPostAsync() { if (!ModelState.IsValid) { return; } Calendar = await _mediator.Send(Query); }
public async Task <HttpResponseMessage> SaveCalendar(CalendarDTO calendar) { try { await _calendarService.SaveCalendar(calendar); return(Request.CreateResponse(HttpStatusCode.OK)); } catch { return(Request.CreateResponse(HttpStatusCode.NotFound)); } }
public async Task <HttpResponseMessage> CreateCalendar([FromBody] CalendarDTO calendar, long accountId) { try { var result = await _calendarService.CreateCalendar(accountId, calendar); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch { return(Request.CreateResponse(HttpStatusCode.NotFound)); } }
public async Task OnGet() { // set start and end dates as this month DateTime today = DateTime.Now; Query = new GetEmployeeCalendarByIdQuery { StartDate = new DateTime(today.Year, today.Month, 1) }; Query.EndDate = Query.StartDate.AddMonths(1).AddDays(-1); Query.EmployeeId = _userManager.GetUserId(User); // get employee data Calendar = await _mediator.Send(Query); }
public async Task <CalendarDTO> CreateCalendar(long accountId, CalendarDTO _calendar) { var account = await _unitOfWork.AccountRepository.GetByIdAsync(accountId); var calendar = CreateClndr(_calendar.StartDate); _unitOfWork.CalendarRepository.Create(calendar); await _unitOfWork.SaveAsync(); List <Book> events; switch (account.Role.Type) { case RoleType.Company: var company = _unitOfWork.CompanyRepository.Query.SingleOrDefault(x => x.Account.Id == accountId); events = _unitOfWork.BookRepository.Query.Where(x => x.Company.Account.Id == company.Account.Id).ToList(); company.Calendar = calendar; _unitOfWork.CompanyRepository.Update(company); await _unitOfWork.SaveAsync(); return(ReturnCalendar(calendar, events)); case RoleType.Vendor: var vendor = _unitOfWork.VendorRepository.Query.SingleOrDefault(x => x.Person.Account.Id == accountId); events = _unitOfWork.BookRepository.Query.Where(x => x.Vendor.Person.Account.Id == vendor.Person.Account.Id).ToList(); vendor.Calendar = calendar; _unitOfWork.VendorRepository.Update(vendor); await _unitOfWork.SaveAsync(); return(ReturnCalendar(calendar, events)); default: return(null); } }
public string EventList(string startDate, string endDate) { List<CalendarDTO> events=null; try { DateTime start, end; start = FromUnixTimespan(startDate); end = FromUnixTimespan(endDate); Task task = new Task(); Collection<Task> taskList = task.GetTaskByStartAndEndDate(start, end); //List to hold events events = new List<CalendarDTO>(); DateTime starting = FromUnixTimespan(startDate); CalendarDTO value; // Loop through events to be added //for (int i = 0; i <= 4; i++) foreach (Task t in taskList) { // Create a new event and start to populate value = new CalendarDTO(); // Date is required to be in a unix format value.StartDate = ToUnixTimespan(t.CompletionDate); value.EndDate = ToUnixTimespan(t.CompletionDate); value.id = t.TaskOID; value.title =t.Subject ; events.Add(value); } } catch (Exception ex) { } // Serialize the return value so it can be decoded in java. System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); return js.Serialize(events); }
public async Task <CalendarDTO> GetAppointments(List <int> Delegations, DatesDTO Fechas, string Query = null, int?StatusId = null, int?RequestTypeId = null) { var calendar = new CalendarDTO(); using (var context = new ISSSTEEntities()) { var appointmentQuery = context.Solicitud .Join(context.TramiteUnidadAtencion, Req => Req.TramiteUnidadAtencionId, Tua => Tua.TramiteUnidadAtencionId, (Req, Tua) => new { req = Req, tua = Tua }) .Select(S => new { Solicitud = S.req, TrammiteUnidadAtencio = S.tua, Paciente = S.req.Involucrado.FirstOrDefault( P => P.CatTipoInvolucradoId == Enumeracion.EnumTipoInvolucrado.Paciente), Promovente = S.req.Involucrado.FirstOrDefault( P => P.CatTipoInvolucradoId == Enumeracion.EnumTipoInvolucrado.Promovente) }) .AsQueryable(); if (!string.IsNullOrEmpty(Query)) { appointmentQuery = appointmentQuery .Where(R => R.Solicitud.NumeroFolio.ToLower().Contains(Query.ToLower()) || R.Paciente.Persona.Nombre.ToLower().Contains(Query.ToLower()) || R.Promovente.Persona.Nombre.ToLower().Contains(Query.ToLower()) ); } if (!Delegations.Contains(Enumeracion.EnumVarios.TodasLasDelegaciones)) { appointmentQuery = appointmentQuery .Where(R => Delegations.Contains(R.TrammiteUnidadAtencio.UnidadAtencionId)); } if (StatusId.HasValue) { appointmentQuery = appointmentQuery.Where(R => R.Solicitud.CatTipoEdoCitaId == StatusId); } if (RequestTypeId.HasValue) { appointmentQuery = appointmentQuery.Where(R => R.TrammiteUnidadAtencio.CatTipoTramiteId == RequestTypeId); } if (Fechas.FechaInicio.HasValue && Fechas.FechaFin.HasValue) { appointmentQuery = appointmentQuery.Where(R => R.Solicitud.FechaCita >= Fechas.FechaInicio && R.Solicitud.FechaCita <= Fechas.FechaFin); } var result = appointmentQuery.Select(S => new AppointmentResultDTO { Id = S.Solicitud.SolicitudId, StartDate = S.Solicitud.FechaCita, EndDate = S.Solicitud.FechaCita, //MFP revisar SolicitudId = S.Solicitud.SolicitudId, NumeroFolio = S.Solicitud.NumeroFolio, HoraCita = S.Solicitud.Horario != null ? S.Solicitud.Horario.HoraInicio : default(TimeSpan), ColorTramite = S.TrammiteUnidadAtencio.CatTipoTramite.Semaforo ?? string.Empty } ); calendar.ListAppointments = await result.ToListAsync(); return(calendar); } }
public async Task <CalendarDTO> GetCalendarByAccountId(long accountId) { var account = await _unitOfWork.AccountRepository.GetByIdAsync(accountId); CalendarDTO calendar; switch (account.Role.Type) { case RoleType.Company: var company = _unitOfWork.CompanyRepository.Query.SingleOrDefault(x => x.Account.Id == accountId); var companyEvents = _unitOfWork.BookRepository.Query.Where(x => x.Company.Account.Id == company.Account.Id); calendar = new CalendarDTO { Id = company.Calendar.Id, StartDate = company.Calendar.StartDate, EndDate = company.Calendar.EndDate, ExtraDayOffs = company.Calendar.ExtraDayOffs.Select(x => new ExtraDayDTO { CalendarId = company.Calendar.Id, Day = x.Day, DayOff = x.DayOff }).ToList(), ExtraWorkDays = company.Calendar.ExtraWorkDays.Select(x => new ExtraDayDTO { CalendarId = company.Calendar.Id, Day = x.Day, DayOff = x.DayOff }).ToList(), Events = companyEvents.Select(x => new VendorBookDTO { Status = x.Status, Customer = x.Customer.Person.Name + " " + x.Customer.Person.Surname, CustomerPhone = x.CustomerPhone, Date = x.Date, EndDate = x.EndDate, Description = x.Description, Work = new WorkDTO { Id = x.Work.Id, Icon = String.IsNullOrEmpty(x.Work.Icon) ? x.Work.Subcategory.Category.Icon : x.Work.Icon, Name = x.Work.Name } }).ToList(), WorkOnWeekend = company.Calendar.WorkOnWeekend, SeveralTasksPerDay = company.Calendar.SeveralTaskPerDay }; return(calendar); case RoleType.Vendor: var vendor = _unitOfWork.VendorRepository.Query.SingleOrDefault(x => x.Person.Account.Id == accountId); var vendorEvents = _unitOfWork.BookRepository.Query.Where(x => x.Vendor.Person.Account.Id == vendor.Person.Account.Id); calendar = new CalendarDTO { Id = vendor.Calendar.Id, StartDate = vendor.Calendar.StartDate, EndDate = vendor.Calendar.EndDate, ExtraDayOffs = vendor.Calendar.ExtraDayOffs.Select(x => new ExtraDayDTO { CalendarId = vendor.Calendar.Id, Day = x.Day, DayOff = x.DayOff }).ToList(), ExtraWorkDays = vendor.Calendar.ExtraWorkDays.Select(x => new ExtraDayDTO { CalendarId = vendor.Calendar.Id, Day = x.Day, DayOff = x.DayOff }).ToList(), Events = vendorEvents.Select(x => new VendorBookDTO { Status = x.Status, Customer = x.Customer.Person.Name + " " + x.Customer.Person.Surname, CustomerPhone = x.CustomerPhone, Date = x.Date, EndDate = x.EndDate, Description = x.Description, Work = new WorkDTO { Id = x.Work.Id, Icon = String.IsNullOrEmpty(x.Work.Icon) ? x.Work.Subcategory.Category.Icon : x.Work.Icon, Name = x.Work.Name } }).ToList(), WorkOnWeekend = vendor.Calendar.WorkOnWeekend, SeveralTasksPerDay = vendor.Calendar.SeveralTaskPerDay }; return(calendar); default: return(null); } }
public JsonResult GetEventsPopup(double start, double end) { string z1; int a; Threshold threshold = new Threshold(); threshold = _ThresholdRepository.Thresholds.First(); var taskList = new List <CalendarDTO>(); IEnumerable <TimeSlot> timeslots = new List <TimeSlot>(); timeslots = _timeSlotRepository.TimeSlots; // To get the calander events IEnumerable <CalendarEvent> events = new List <CalendarEvent>(); events = _eventsRepository.CalendarEvents; //IEnumerable<User> users = new List<User>(); //users = _UserRepository.GetAllUsersByRole(3); // a = users.Count(); //The following creates all time slots form 2011 to 2020 //make sure you update the time slots based on the number of users, this should just be used as a temporary thing /* #region Create all time slots * TimeSlot newTimeSlot = new TimeSlot(); * int nextHour; * for (int year = 2011; year <= 2011; year++) * { * for (int month = 1; month <= 12; month++) * { * for (int day = 1; day <= 31; day++) * { * for (int hour = 9; hour <= 17; hour++) * { * nextHour = hour + 1; * newTimeSlot.Title = a; * newTimeSlot.StartTime = year + "-" + zeroPad(month) + "-" + zeroPad(day) + "T" + zeroPad(hour) + ":00:00"; * newTimeSlot.EndTime = year + "-" + zeroPad(month) + "-" + zeroPad(day) + "T" + zeroPad(nextHour) + ":00:00"; * newTimeSlot.Color = "green"; * newTimeSlot.Num_Available_SA = a; * _timeSlotRepository.SaveTimeSlot(newTimeSlot); * * } * } * } * } #endregion */ foreach (var timeslot in timeslots) { CalendarDTO taList = new CalendarDTO(); taList.id = timeslot.TimeSlotId; taList.start = timeslot.StartTime; taList.end = timeslot.EndTime; taList.backgroundColor = timeslot.Color; taList.title = timeslot.Title.ToString(); taList.availableSAs = timeslot.Num_Available_SA; taList.allDay = false; taskList.Add(taList); } //return Json(cal.ToArray(), JsonRequestBehavior.AllowGet); return(Json(taskList.ToArray(), JsonRequestBehavior.AllowGet)); }