public ActionResult Save(Customer customers)
        {
            bool status = false;

            //ViewBag.Country = new SelectList(db.MCountries, "iCountry", "strCountryName", customers.iCountry);
            //ViewBag.City = new SelectList(db.MCities, "iCity", "strCityName", customers.iCity);


            try
            {
                if (ModelState.IsValid)
                {
                    Services.CustomerServiceClient customerServiceClient = new Services.CustomerServiceClient();
                    status = customerServiceClient.SaveData(customers);

                    //ViewBag.Country = new SelectList(db.MCountries, "iCountry", "strCountryName", customers.iCountry);
                    //ViewBag.City = new SelectList(db.MCities, "iCity", "strCityName", customers.iCity);


                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong");
                status = false;
                throw e;
            }
            return(View(customers));
            // return new JsonResult { Data = new { status = status } };
        }
Ejemplo n.º 2
0
        public ActionResult Save(Customer customers)
        {
            bool status = false;

            ViewBag.CutomerType = new SelectList(db.MCutomerTypes, "iCutomerTypeID", "strCutomerTypeName", customers.iCutomerTypeID);

            ViewBag.Country        = new SelectList(db.MCountries, "iCountry", "strCountryName", customers.iCountry);
            ViewBag.City           = new SelectList(db.MCities, "iCity", "strCityName", customers.iCity);
            ViewBag.CreditCategory = new SelectList(db.CreditCategories, "iCreditCategoryID", "strCategory", customers.iCreditCategoryID);


            try
            {
                if (ModelState.IsValid)
                {
                    HttpPostedFileBase             fileIDCopy            = Request.Files["IDCopyImageData"];
                    HttpPostedFileBase             fileVisaCopy          = Request.Files["VisaCopyImageData"];
                    Services.CustomerServiceClient customerServiceClient = new Services.CustomerServiceClient();


                    status = customerServiceClient.SaveData(customers, fileIDCopy, fileVisaCopy);

                    ViewBag.CutomerType = new SelectList(db.MCutomerTypes, "iCutomerTypeID", "strCutomerTypeName", customers.iCutomerTypeID);

                    ViewBag.Country = new SelectList(db.MCountries, "iCountry", "strCountryName", customers.iCountry);
                    ViewBag.City    = new SelectList(db.MCities, "iCity", "strCityName", customers.iCity);


                    return(RedirectToAction("Index", "MCustomer"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong");
                status = false;
                throw e;
            }
            return(View(customers));
            // return new JsonResult { Data = new { status = status } };
        }