public IActionResult Post([FromBody] CustomRequestMobile data)
        {
            if (data.Category.Equals("Select Category"))
            {
                return(NotFound());
            }
            if (data.Description.Equals(""))
            {
                return(NotFound());
            }
            if (data.RequestQty.Equals(""))
            {
                return(NotFound());
            }

            string employeeId = data.EmployeeId.ToString();
            int    RequestId  = requestService.addRequest(employeeId);

            CustomRequestDetails crq = new CustomRequestDetails();

            crq.Category    = data.Category;
            crq.Description = data.Description;
            crq.Qty         = data.RequestQty;

            InventoryItem findItem = new InventoryItem();

            findItem   = inventService.GetItemByDescription(crq.Description);
            crq.ItemId = findItem.Id;
            requestService.AddRequestDetailsMobile(RequestId, crq);
            emailservice.sendrequestsubmitemailnotifitcation(data.EmployeeId);
            return(Ok(crq));
        }
        public IActionResult RepeatRequest(int id)
        {
            if (!(HttpContext.Session.GetString("role") == EmployeeRole.EMPLOYEE || HttpContext.Session.GetString("role") == EmployeeRole.DEPTREP))
            {
                return(RedirectToAction(HttpContext.Session.GetString("role"), "Home"));
            }
            string employeeId = HttpContext.Session.GetString("id");
            List <RequestDetails> requestDetails = requestDetailService.FindRequestDetailByRequestId(id);
            int requestId = requestService.addRequest(employeeId);
            List <CustomRequestDetails> customRequestDetailsList = new List <CustomRequestDetails>();

            foreach (RequestDetails rd in requestDetails)
            {
                CustomRequestDetails cusReqDet = new CustomRequestDetails();
                cusReqDet.Category    = rd.InventoryItem.ItemCategory.Name;
                cusReqDet.Description = rd.InventoryItem.Description;
                cusReqDet.ItemId      = rd.InventoryItemId;
                cusReqDet.Qty         = Convert.ToString(rd.QtyRequested);

                customRequestDetailsList.Add(cusReqDet);
            }
            requestService.AddRequestDetails(requestId, customRequestDetailsList);
            //email notification to employee to indicate successful submission
            emailService.sendrequestsubmitemailnotifitcation(int.Parse(employeeId));
            //email notification to ActingHead or DepartmentHead to review request
            emailService.sendPendingApprovalEmailNotification(int.Parse(employeeId));
            TempData["repeatRequestStatus"] = "success";
            return(RedirectToAction("ViewMyRequestHistory"));
        }
Exemplo n.º 3
0
        public void AddRequestDetailsMobile(int requestId, CustomRequestDetails reqDetail)
        {
            RequestDetails addDetail = new RequestDetails();

            addDetail.RequestId       = requestId;
            addDetail.QtyRequested    = int.Parse(reqDetail.Qty);
            addDetail.InventoryItemId = reqDetail.ItemId;
            dbcontext.Add(addDetail);
            dbcontext.SaveChanges();
        }