public async Task <bool> Update(SlotDTM slotDtm) { try { Slot slot = new Slot(); slot.Id = slotDtm.Id; slot.SlotDateTime = slotDtm.SlotDateTime /*?? DateTime.Now*/; slot.Duration = slotDtm.Duration; slot.IsPadding = slotDtm.IsPadding; slot.PaddingAfter = slotDtm.PaddingAfter; slot.Reiteration = slotDtm.Reiteration; slot.Price = slotDtm.Price; slot.Note = slotDtm.Note; slot.Status = slotDtm.Status; slot.IsTimeBlock = slotDtm.IsTimeBlock; slot.IsReminderNeeded = slotDtm.IsReminderNeeded; slot.ReminderInterval = slotDtm.ReminderInterval; slot.Employee = await Database.BllServices.GetEmployee(slotDtm.Employee.Id);// check here slot.Responsible = await Database.BllServices.GetEmployee(slotDtm.Responsible.Id); slot.Country = await Database.BllServices.GetCountry(slotDtm.Country.Id); slot.Service = await Database.BllServices.GetService(slotDtm.Service.Id); return(await Database.Slotes.Update(slot) ? true : false); } catch (Exception ex) { Console.Out.WriteLine(ex.Message); return(false); } }
public async Task <int> Create(SlotDTM slotDtm) { try { //Slot slot = new Slot(); //slot.SlotDateTime = DateTime.Now; //slot.Duration = 15; //slot.IsPadding = true; //slot.PaddingAfter = 20; //slot.Reiteration = 30; //slot.Price = 15f; //slot.Note = "sdfsf"; //slot.Status = "sdfsd sdf "; //slot.IsTimeBlock = false; //slot.IsReminderNeeded = true; //slot.ReminderInterval = 15; //slot.Employee = await Database.BllServices.GetEmployee(1); //slot.Responsible = await Database.BllServices.GetEmployee(1); //slot.Country = await Database.BllServices.GetCountry(5); //slot.Service = await Database.BllServices.GetService(1); Slot slot = new Slot(); slot.SlotDateTime = slotDtm.SlotDateTime /*?? DateTime.Now*/; slot.Duration = slotDtm.Duration; slot.IsPadding = slotDtm.IsPadding; slot.PaddingAfter = slotDtm.PaddingAfter; slot.Reiteration = slotDtm.Reiteration; slot.Price = slotDtm.Price; slot.Note = slotDtm.Note; slot.Status = slotDtm.Status; slot.IsTimeBlock = slotDtm.IsTimeBlock; slot.IsReminderNeeded = slotDtm.IsReminderNeeded; slot.ReminderInterval = slotDtm.ReminderInterval; slot.Employee = await Database.BllServices.GetEmployee(slotDtm.Employee.Id); //slot.EmployeeId = slotDtm.Employee.Id; slot.Responsible = await Database.BllServices.GetEmployee(slotDtm.Responsible.Id); //slot.ResponsibleId = slotDtm.Responsible.Id; slot.Country = await Database.BllServices.GetCountry(slotDtm.Country.Id); //slot.CountryId = slotDtm.Country.Id; slot.Service = await Database.BllServices.GetService(slotDtm.Service.Id); await Database.Slotes.Create(slot); return(slot.Id); } catch { return(0); } }
// POST: /Slots/slotDTM public async Task <HttpResponseMessage> Post([FromBody] SlotDTM slotDtm) { try { int id = await TheRepo.SlotesDTM.Create(slotDtm); return(Request.CreateResponse(HttpStatusCode.Created, id)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <SlotDTM> Get(int id) { int firstSlotId = 1; if (id < firstSlotId) { throw new ValidationException("Slot id is not specified correctly", ""); } var slot = await Database.Slotes.Get(id); if (slot == null) { throw new ValidationException("Slot is not found", ""); } SlotDTM slotDtm = new SlotDTM(); slotDtm.Id = slot.Id; slotDtm.SlotDateTime = slot.SlotDateTime; slotDtm.Duration = slot.Duration; slotDtm.IsPadding = slot.IsPadding; slotDtm.PaddingAfter = slot.PaddingAfter; slotDtm.Reiteration = slot.Reiteration; slotDtm.Price = slot.Price; slotDtm.Note = slot.Note; slotDtm.Status = slot.Status; slotDtm.IsTimeBlock = slot.IsTimeBlock; slotDtm.IsReminderNeeded = slot.IsReminderNeeded; slotDtm.ReminderInterval = slot.ReminderInterval; slotDtm.EmployeeId = slot.EmployeeId; slotDtm.ResponsibleId = slot.ResponsibleId; slotDtm.CountryId = slot.CountryId; slotDtm.ServiceId = slot.ServiceId; //slotDtm.Employee = await Database.BllServices.GetEmployee(slot.Employee.Id); //slotDtm.EmployeeId = slot.Employee.Id; //slotDtm.Responsible = await Database.BllServices.GetEmployee(slot.Responsible.Id); //slotDtm.ResponsibleId = slot.Responsible.Id; //slotDtm.Country = await Database.BllServices.GetCountry(slot.Country.Id); //slotDtm.CountryId = slot.Country.Id; //slotDtm.Service = await Database.BllServices.GetService(slot.Service.Id); return(slotDtm); }
public HttpResponseMessage Put([FromBody] SlotDTM slotDtm) { try { var originalSlot = TheRepo.SlotesDTM.Get(slotDtm.Id); if (originalSlot == null) { return(Request.CreateResponse(HttpStatusCode.NotModified, "Slot is not found")); } else { TheRepo.SlotesDTM.Update(slotDtm); return(Request.CreateResponse(HttpStatusCode.OK, slotDtm)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public SlotDTM SlotToSlotDtmMap(Slot slot) { SlotDTM slotDtm = new SlotDTM(); slotDtm.Id = slot.Id; slotDtm.SlotDateTime = slot.SlotDateTime; slotDtm.Duration = slot.Duration; slotDtm.IsPadding = slot.IsPadding; slotDtm.PaddingAfter = slot.PaddingAfter; slotDtm.Reiteration = slot.Reiteration; slotDtm.Price = slot.Price; slotDtm.Note = slot.Note; slotDtm.Status = slot.Status; slotDtm.IsTimeBlock = slot.IsTimeBlock; slotDtm.IsReminderNeeded = slot.IsReminderNeeded; slotDtm.ReminderInterval = slot.ReminderInterval; slotDtm.EmployeeId = slot.EmployeeId; slotDtm.ResponsibleId = slot.ResponsibleId; slotDtm.CountryId = slot.CountryId; slotDtm.ServiceId = slot.ServiceId; return(slotDtm); }