public IActionResult ApproveByScrumMaster(int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } if (requestMedical.HasFeedbackByScrumMaster() || requestMedical.HasFeedbackByHumanResource()) { this.ModelState.AddModelError("id", "Already have feedback by Scrum Master or HR"); } if (this.ModelState.IsValid) { // TODO : find correct Employee ID from Username requestMedical.ScrumMasterApproved(10, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } else { return(BadRequest()); } }
public ActionResult Create(RequestMedicalCreateViewModel model) { if (this.ModelState.IsValid) { RequestMedical requestMedical = model.ToRequestMedicalEntity(); this.Storage.GetRepository <IRequestMedicalRepository>().Create(requestMedical, this.GetCurrentUserName()); this.Storage.Save(); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult Get(int id) { var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } return(Ok(new { success = true, data = requestMedical })); }
public IActionResult ApproveByHumanResourceDept(int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } return(Ok(new { success = true })); }
public IActionResult RejectByHumanResourceDept([FromRoute] int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } requestMedical.HumanResourceDeptRejected(20, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); }
public IActionResult Delete(int id) { var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } repo.Delete(requestMedical, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); }
public IActionResult ApproveByScrumMaster(int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } // TODO : find correct Employee ID from Username // quickLeave.ScrumMasterApproved(0); return(Ok(new { success = true })); }
public async Task <IActionResult> Post(RequestMedicalCreateViewModel model) { if (this.ModelState.IsValid) { RequestMedical requestMedical = model.ToEntity(); var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); // var imageUrl = await _imageService.UploadImageAsync(model.Image); // requestMedical.ImageUrl = imageUrl.ToString(); repo.Create(requestMedical, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }
public IActionResult Put(int id, RequestMedicalUpdateViewModel model) { var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } if (this.ModelState.IsValid) { model.ToEntity(requestMedical, this.GetCurrentUserName()); repo.Edit(requestMedical, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }
public IActionResult RejectByHumanResourceDept([FromRoute] int id) { var username = this.GetCurrentUserName(); var repo = this.Storage.GetRepository <IRequestMedicalRepository>(); RequestMedical requestMedical = repo.WithKey(id); if (requestMedical == null) { return(this.NotFound(new { success = false })); } if (requestMedical.HasFeedbackByScrumMaster() || requestMedical.HasFeedbackByHumanResource()) { this.ModelState.AddModelError("id", "Already have feedback by Srum Master or HR"); } if (ModelState.IsValid) { requestMedical.HumanResourceDeptRejected(20, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest()); }