Esempio n. 1
0
        public ActionResult Acknowledge(DisbursementDetailDTO disbursementDto, string update)
        {
            if (disbursementDto == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                var disbursement = _disbursementRepo.GetById(disbursementDto.CurrentDisbursement.DisbursementId);

                //set the actual qty of its detail list items to the updated qty, and update it in database
                foreach (var disbursementDetail in disbursement.DisbursementDetails)
                {
                    disbursementDetail.ActualQty = disbursementDto.DisDetailList
                                                   .First(ddEdited => ddEdited.ItemNum == disbursementDetail.ItemNum)
                                                   .ActualQty;
                }

                _disbursementRepo.Update(disbursement);

                switch (update)
                {
                //case 1: confirm items disbursed and update stationery qty
                case "Acknowledge Manually":
                    _disbursementRepo.Acknowledge(disbursement);
                    foreach (var dd in disbursement.DisbursementDetails)
                    {
                        var stationery = _stationeryRepo.GetById(dd.Stationery.ItemNum);
                        stationery.CurrentQty -= dd.ActualQty;
                        _stationeryRepo.Update(stationery);
                    }

                    return(RedirectToAction("Upcoming"));

                //case 2: only updates actual qty and leave changing status and deduct stock qty to WebAPI
                case "Generate QR Code":
                    break;
                }

                return(Json("Ok"));
            }

            return(View("Details", disbursementDto));
        }
Esempio n. 2
0
        // GET: Disbursement/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var disbursement = _disbursementRepo.GetById((int)id);

            if (disbursement == null)
            {
                return(HttpNotFound());
            }

            var disDetailDto = new DisbursementDetailDTO
            {
                CurrentDisbursement = disbursement,
                DisDetailList       = disbursement.DisbursementDetails.ToList()
            };

            return(View(disDetailDto));
        }