public bool CreateDayOff(DayOffRequest request) { try { Entities.DayOffRequests.Add(request); Entities.SaveChanges(); return(true); }catch (Exception ex) { throw ex; } }
public bool CreateDayOff(DayOffRequest request) { try { return(dayOffRequestRepositories.CreateDayOff(new Repositories.Context.Entities.DayOffRequest { RequestId = Guid.NewGuid().ToString(), RequestedShiftId = request.RequestedShiftId, RequestEmployeeId = request.RequestEmployeeId, RequestedAt = DateTime.Now, Status = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING), Reason = request.Reason })); }catch (Exception ex) { throw ex; } }
public ActionResult Create(AddDayOffRequestVM request) { try { var userInfo = CookieHelpers.GetUserInfo(); var dayOffRequest = new DayOffRequest { RequestedShiftId = request.ShiftId, RequestEmployeeId = userInfo.EmployeeId, RequestedAt = DateTime.Now, Reason = request.Reason, Status = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING) }; var isAdded = dayOffRequestServices.CreateDayOff(dayOffRequest); return(Json(new BaseViewModel <bool>(true, string.Empty, isAdded), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new BaseViewModel <bool>(true, ex.Message, false), JsonRequestBehavior.AllowGet)); } }