Exemple #1
0
        public ActionResult JsonParentCommodities(int commodityTypeID, int?editModval)
        {
            var parentCommodities =
                _commodityService.Get(t => t.ParentID == null && t.CommodityTypeID == commodityTypeID);

            if (parentCommodities != null)
            {
                var parentCommoditiesSelectList = new SelectList(parentCommodities.ToList(), "CommodityID", "Name", editModval);
                return(Json(parentCommoditiesSelectList, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult Details(int id)
        {
            var localPurchase     = _localPurchaseService.FindById(id);
            var parentCommodityID = _commodityService.Get(m => m.CommodityID == localPurchase.CommodityID).FirstOrDefault().ParentID;

            ViewBag.ProgramID       = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name", localPurchase.ProgramID);
            ViewBag.CommodityID     = new SelectList(_commodityService.FindBy(m => m.ParentID == parentCommodityID), "CommodityID", "Name", localPurchase.CommodityID);
            ViewBag.CommodityTypeID = new SelectList(_commonService.GetCommodityTypes(), "CommodityTypeID", "Name");
            ViewBag.DonorID         = new SelectList(_commonService.GetDonors(), "DonorID", "Name", localPurchase.DonorID);
            if (localPurchase != null)
            {
                var localPurchaseWithDetailViewModel = new LocalPurchaseWithDetailViewModel()
                {
                    LocalPurchaseID = localPurchase.LocalPurchaseID,
                    ProgramID       = localPurchase.ProgramID,
                    DonorID         = localPurchase.DonorID,
                    CommodityID     = localPurchase.DonorID,
                    ProjectCode     = localPurchase.ProjectCode,
                    SINumber        = localPurchase.ShippingInstruction.Value,
                    ReferenceNumber = localPurchase.ReferenceNumber,
                    SupplierName    = localPurchase.SupplierName,
                    PurchaseOrder   = localPurchase.PurchaseOrder,
                    Quantity        = localPurchase.Quantity,
                    StatusID        = localPurchase.StatusID,
                    CommoditySource = _commonService.GetCommditySourceName(3),    //commodity source for local purchase
                    LocalPurchaseDetailViewModels = GetLocalPurchaseDetail(localPurchase.LocalPurchaseDetails)
                };
                if (TempData["CustomError"] != null)
                {
                    ModelState.AddModelError("Errors", TempData["CustomError"].ToString());
                }
                if (TempData["success"] != null)
                {
                    ModelState.AddModelError("Success", TempData["success"].ToString());
                }
                return(View(localPurchaseWithDetailViewModel));
            }
            return(RedirectToAction("Index"));
        }