Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 3
0
        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 }));
        }
Ejemplo n.º 4
0
        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 }));
        }
Ejemplo n.º 5
0
        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 }));
        }
Ejemplo n.º 6
0
        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 }));
        }
Ejemplo n.º 7
0
        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 }));
        }
Ejemplo n.º 8
0
        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 }));
        }
Ejemplo n.º 9
0
        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 }));
        }
Ejemplo n.º 10
0
        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());
        }