public void Add(SchedulingViewModel fieldViewModel) { if (fieldViewModel.HoraryType != Domain.Others.Enum.HoraryType.Default) { fieldViewModel.HoraryExtraId = fieldViewModel.HoraryId; fieldViewModel.HoraryId = null; } _schedulingRepository.Add(_mapper.Map <Scheduling>(fieldViewModel)); }
public void CreateScheduling(Scheduling scheduling, int totalBlock, string userName) { //tạo scheduling scheduling.DateCreated = DateTime.Now; scheduling.CreatedByUserName = userName; _schedulingRepository.Add(scheduling); //tạo block CreateBlocks(scheduling, totalBlock); }
public Scheduling Save(Scheduling data) { data.Room = MeetingRoomRepository.Find(data.Room.MeetingRoomId); SchedulingRepository.Add(data); return(data); }
public void Post([FromBody] Scheduling value) { _schedulingRepository.Add(value); }
public ResponseModel CreateScheduling(CreateSchedulingModel model) { var resp = new ResponseModel(); try { Client client = _clientRepository.GetClientByUserId(Guid.Parse(model.UserId)); if (client == null) { resp.Message = "Não foi possível encontrar o cliente"; return(resp); } Employee employee = _employeeRepository.GetById(Guid.Parse(model.EmployeeId)); if (employee == null) { resp.Message = "Não foi possível encontrar o funciónário"; return(resp); } Domain.Entities.Services service = _serviceRepository.GetById(Guid.Parse(model.ServiceId)); if (service == null) { resp.Message = "Não foi possível encontrar o serviço"; return(resp); } DateTime startTime; if (!DateTime.TryParse(model.StartTime, out startTime)) { resp.Message = "Start time inválida"; return(resp); } DateTime endTime; if (!DateTime.TryParse(model.EndTime, out endTime)) { resp.Message = "End time inválida"; return(resp); } Scheduling newScheduling = new Scheduling { SchedulingId = Guid.NewGuid(), EmployeeId = Guid.Parse(model.EmployeeId), ClientId = client.ClientId, ServiceId = Guid.Parse(model.ServiceId), StartTime = startTime, EndTime = endTime, CreatedAt = DateTimeUtil.UtcToBrasilia(), LastUpdatedAt = DateTimeUtil.UtcToBrasilia() }; _schedulingRepository.Add(newScheduling); Scheduling scheduling = _schedulingRepository.GetSchedulingByIdComplete(newScheduling.SchedulingId); if (scheduling == null) { resp.Message = "Falha ao realizar o agendamento"; return(resp); } resp.Success = true; resp.Message = "Agendamento realizado com sucesso!"; resp.Result = SchedulingToGetSchedulingModel(scheduling); } catch (Exception e) { resp.Message = $"Não foi possível realizar o agendamento. {e.Message}"; } return(resp); }