예제 #1
0
        public ActionResult EditBase(String id, CustomerSupplierBase csB)
        {
            //Load each type of base
            ViewBag.TypeOfBaseList = typeOfBaseRepository.GetAll();

            if (ModelState.IsValid)
            {
                try
                {
                    customerSupplierBaseRepository.Edit(csB);
                    customerSupplierBaseRepository.Save();
                    return Json(new { redirectUrl = Url.Action("IndexBase", new { id = csB.CodCustomerSupplier })});
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, "Something went wrong. Message: " + ex.Message);
                }
            }
            ViewBag.ActionMethod = "EditBase";

            //If we come here, something went wrong. Return it back.        
            return PartialView("_EditAndCreateBase",csB);           
        }
예제 #2
0
        //
        // GET: /CustomerSupplierBase/Create

        public ActionResult CreateBase(string id)
        {
            //TODO Algola: cercare gli indirizzi del cliente se non c'è la sede principale impostare subito a quella
            //find all customer bases
            var codCliSupBases = (from X in customerSupplierBaseRepository.FindBy(x=>x.CodCustomerSupplier==id) select X.CodCustomerSupplierBase).Max();
            if (codCliSupBases == null)
                codCliSupBases = id + "CODA001";

            //Load each type of base
            ViewBag.TypeOfBaseList = typeOfBaseRepository.GetAll();
                        
            CustomerSupplierBase cs = new CustomerSupplierBase();
            cs.CodCustomerSupplier = id;
            cs.CodCustomerSupplierBase = AlphaCode.GetNextCode(codCliSupBases);
            //find if there is one SedePricipale
            var NumMainBase = from X in customerSupplierBaseRepository.FindBy(x => x.CodCustomerSupplier == id) where X.CodTypeOfBase == "0001" select X;
            if (NumMainBase.Count() < 1)
            {
                cs.CodTypeOfBase = "0001";
            }
            else
            {
                cs.CodTypeOfBase = "0002";
            }
//            ViewBag.TypeOfBaseList = 

            ViewBag.ActionMethod = "CreateBase";
            return View(cs);
        }
예제 #3
0
        public ActionResult CreateBase(CustomerSupplierBase cs)
        {
            //Load each type of base
            ViewBag.TypeOfBaseList = typeOfBaseRepository.GetAll();
            
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add insert logic here
                    var c = customerSupplierRepository.GetSingle(cs.CodCustomerSupplier);
                    cs.TimeStampTable = DateTime.Now;
                    c.CustomerSupplierBases.Add(cs);
                    
                    //clisupDataRep.Edit(c);                    
                    customerSupplierRepository.Save();
                    return Json(new { redirectUrl = Url.Action("IndexBase", new {id=cs.CodCustomerSupplier})});
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, "Something went wrong. Message: " + ex.Message);
                }
        }

            ViewBag.ActionMethod = "CreateBase";

            //If we come here, something went wrong. Return it back.        
            return PartialView("_EditAndCreateBase",cs);            
        }
예제 #4
0
 public SupplierViewModel()
 {
     customerSupplier = new Supplier();
     CustomerSupplierBase = new CustomerSupplierBase();
 }