public ActionResult Apply(ApplyForLeaveViewModel model) { BLLLeave _leave = new BLLLeave(); JsonResult json = new JsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; model.PeriodFrom = Convert.ToDateTime(model.PeriodFrom).ToShortDateString(); model.PeriodTo = Convert.ToDateTime(model.PeriodTo).ToShortDateString(); string result = "error"; if(_leave.Apply(User.IDNO, model)) { //Email manager BLLEmail _email = new BLLEmail(); if(_email.EmailManager(model)) { result = "success"; } } json.Data = new { result = result }; return json; }
public ActionResult Respond(LeaveViewModel model) { BLLLeave _leave = new BLLLeave(); JsonResult json = new JsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; string result = "error"; if (_leave.UpdateLeaveStatus(User.IDNO, model)) { model = _leave.GetLeaveInfo(model.LeaveID); BLLEmail _email = new BLLEmail(); if(_email.EmailEmployee(model)) { result = "success"; } } json.Data = new { result = result, id = model.LeaveID, status = model.LeaveStatus }; return json; }