public IActionResult AddShiftType(ShiftTypeModel shiftTypeModel) { try { ShiftTypeModel addedShiftType = logic.AddShiftTypeModel(shiftTypeModel); return(Created("api/shifts/shift_types/" + addedShiftType.ShiftTypeId, addedShiftType)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public IActionResult GetOneShiftType(int id) { try { ShiftTypeModel shiftType = logic.GetSingleShiftType(id); if (shiftType == null) { return(NotFound($"id {id} not found")); } return(Ok(shiftType)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public IActionResult UpdatePartialShiftType(int id, ShiftTypeModel shiftTypeModel) { try { shiftTypeModel.ShiftTypeId = id; ShiftTypeModel updatedShiftType = logic.UptdatePartialShiftType(shiftTypeModel); if (updatedShiftType == null) { return(NotFound($"id {id} not found")); } return(Ok(updatedShiftType)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public IHttpActionResult UpdateShiftType(ShiftTypeModel shiftTypeModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var shiftTypeDto = Mapper.Map <ShiftTypeDto>(shiftTypeModel); _shiftTypeAppService.Update(shiftTypeDto, AuthHelper.GetCurrentUserId()); return(Ok("Shift Type Update")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }