Ejemplo n.º 1
0
        public async Task PreparePOItemModel(RFPItemModel model, Rfpitem rfpitem,
                                             int rfpVendorId)
        {
            foreach (var item in (await SelectGl((int)_workContext.CurrentCustomer.ClientId)))
            {
                model.AvailableGl.Add(new SelectListItem {
                    Text = item.GLFull, Value = item.GL
                });
            }

            foreach (var item in (await SelectShipTo((int)_workContext.CurrentCustomer.ClientId)))
            {
                model.AvailableShipTo.Add(new SelectListItem {
                    Text = item.Both, Value = item.ShipID
                });
            }

            model.RfpvendorId = rfpVendorId;

            var rfpvendor = await _rfpVendorRepository.Table.Where(v => v.RfpvendorId == rfpVendorId).FirstOrDefaultAsync();

            if (rfpvendor != null)
            {
                model.rfpName = rfpvendor.Rfpvname;
            }
            else
            {
                model.rfpName = "None";
            }
        }
        public async Task <IActionResult> OpenPOItem2(RFPItemModel model)
        {
            if (ModelState.IsValid)
            {
                var rfpitemObj = _mapper.Map <Rfpitem>(model);

                var result = await _rfqService.InsertRfpItem(rfpitemObj);

                if (result)
                {
                    SuccessNotification("The PO item data has been saved successfully.");
                    return(RedirectToAction("OpenPOItem2", "RFQ",
                                            new { PFVENDORID = rfpitemObj.RfpvendorId }));
                }
                else
                {
                    ModelState.AddModelError("", "Something went wrong while saving record");
                }
            }

            //if we got so far, and something went failed redisplay form
            await _rfqService.PreparePOItemModel(model, null, Convert.ToInt32(model.Rfpid));

            return(View(model));
        }
        public async Task <IActionResult> RFPAddItem(int RFPID)
        {
            if (RFPID == 0)
            {
                return(RedirectToAction("ProcessRFQ"));
            }

            var model = new RFPItemModel();
            await _rfqService.PrepareRFQItemModel(model, null, Convert.ToInt32(RFPID));

            return(View(model));
        }
        public async Task <IActionResult> OpenPOItem2(int PFVENDORID)
        {
            if (PFVENDORID == 0)
            {
                return(RedirectToAction("OpenPO2"));
            }

            var model = new RFPItemModel();
            await _rfqService.PreparePOItemModel(model, null, PFVENDORID);

            model.PFVENDORID = PFVENDORID;

            return(View(model));
        }
Ejemplo n.º 5
0
        public async Task PrepareRFQItemModel(RFPItemModel model, Rfpitem rfpitem, int RfpPID)
        {
            var RFPrfq = await GetRfpNamesById(Convert.ToInt32(RfpPID));

            model.rfpName     = RFPrfq.Rfptitle;
            model.RfpvendorId = (await GetRfpvendors(Convert.ToInt32(RfpPID))).Select(c => c.RfpvendorId).FirstOrDefault();

            foreach (var item in (await SelectGl((int)_workContext.CurrentCustomer.ClientId)))
            {
                model.AvailableGl.Add(new SelectListItem {
                    Text = item.GLFull, Value = item.GL
                });
            }

            foreach (var item in (await SelectShipTo((int)_workContext.CurrentCustomer.ClientId)))
            {
                model.AvailableShipTo.Add(new SelectListItem {
                    Text = item.Both, Value = item.ShipID
                });
            }
        }
        public async Task <IActionResult> RFPItem2Edit(RFPItemModel model)
        {
            if (ModelState.IsValid)
            {
                var rfpitemObj = _mapper.Map <Rfpitem>(model);
                var result     = await _rfqService.UpdateRfpItem(rfpitemObj);

                if (result)
                {
                    SuccessNotification("The RFQ item data has been updated successfully.");
                    return(RedirectToAction("RFPItem2Edit", "RFQ",
                                            new { RFPItemID = model.RfpitemId, RFPID = model.Rfpid }));
                }
                else
                {
                    ModelState.AddModelError("", "Something went wrong while saving record");
                }
            }

            //if we got so far, and something went failed redisplay form
            await _rfqService.PrepareRFQItemModel(model, null, Convert.ToInt32(model.Rfpid));

            return(View(model));
        }