public IActionResult ApproveByScrumMaster(int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } // TODO : find correct Employee ID from Username if (quickLeave.HasFeedbackByScrumMaster() || quickLeave.HasFeedbackByHumanResource()) { this.ModelState.AddModelError("id", "Already have feedback by Scrum Master or HR"); } if (this.ModelState.IsValid) { // TODO : find correct Employee ID from Username quickLeave.ScrumMasterApproved(10, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } else { return(BadRequest()); } }
public IActionResult Put(int id, QuickLeaveUpdateViewModel model) { var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } //if (quickLeave == null) //{ // return NotFound("The Employee record couldn't be found."); //} if (this.ModelState.IsValid) { model.ToEntity(quickLeave, this.GetCurrentUserName()); repo.Edit(quickLeave, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }
public ActionResult Create(QuickLeaveCreateViewModel model) { if (this.ModelState.IsValid) { QuickLeave quickLeave = model.ToQuickLeaveEntity(); this.Storage.GetRepository <IQuickLeaveRepository>().Create(quickLeave, this.GetCurrentUserName()); this.Storage.Save(); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult Get(int id) { var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } return(Ok(new { success = true, data = quickLeave })); }
public IActionResult Post(QuickLeaveCreateViewModel model) { if (this.ModelState.IsValid) { QuickLeave quickLeave = model.ToEntity(); quickLeave.GetTotalTimeTaken(); var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); repo.Create(quickLeave, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }
public IActionResult Delete(int id) { var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } repo.Delete(quickLeave, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); }
public IActionResult RejectByHumanResourceDept([FromRoute] int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } quickLeave.HumanResourceDeptRejected(20, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); }
public IActionResult ApproveByHumanResourceDept(int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } return(Ok(new { success = true })); }
public IActionResult Get(int id) { var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); //if (quickLeave == null) //{ // return NotFound("The Employee record couldn't be found."); //} if (quickLeave == null) { return(this.NotFound(new { success = false })); } return(Ok(new { success = true, data = quickLeave })); }
public IActionResult ApproveByScrumMaster(int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } // TODO : find correct Employee ID from Username // quickLeave.ScrumMasterApproved(0); return(Ok(new { success = true })); }
public IActionResult RejectByHumanResourceDept([FromRoute] int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IQuickLeaveRepository>(); QuickLeave quickLeave = repo.WithKey(id); if (quickLeave == null) { return(this.NotFound(new { success = false })); } if (quickLeave.HasFeedbackByScrumMaster() || quickLeave.HasFeedbackByHumanResource()) { this.ModelState.AddModelError("id", "Already have feedback by Srum Master or HR"); } if (ModelState.IsValid) { quickLeave.HumanResourceDeptRejected(20, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest()); }