public async Task <bool> EditAppointment(EditAppointmentModel appModel) { try { var appointment = _context.Appointments.FirstOrDefault(app => app.GuidID.ToString() == appModel.GuidID.ToString()); _context.Appointments.Remove(appointment); var editedApp = new Appointment() { GuidID = appModel.GuidID, AppointmentDate = appModel.AppointmentDate.AddDays(1), AppointmentHour = appModel.AppointmentHour, CreatedOn = appModel.CreatedOn, UserName = appModel.UserName }; await _context.Appointments.AddAsync(editedApp); await _context.SaveChangesAsync(); return(true); } catch (Exception e) { throw e; } }
public async Task <object> DeleteAppointment(EditAppointmentModel model) { try { if (!await _appService.IsAppointmentExistById(model.GuidID.ToString())) { return(BadRequest(new { message = "Appointment is not exist" })); } var result = await _appService.DeleteAppointment(model.GuidID.ToString()); if (result) { return(Ok(result)); } return(BadRequest(new { message = "Operation failed, servers are down at the moment" })); } catch (Exception e) { return(BadRequest(new { e.Message })); } }
public async Task <bool> EditAppointment(EditAppointmentModel model) { return(await _appointmentRepository.EditAppointment(model)); }