Example #1
0
 public ActionResult AddNewCustomer(CustomerContract model)
 {
     try
     {
         //var myViewObj = new CustomerContract();
         //var customer = ServiceProvider.Instance().GetCustomerServices().GetCustomers() ?? new List<CustomerContract>();
         //myViewObj.Countrys = new SelectList(countryList, "CountryId", "Name", model.CountryId);
         if (!ModelState.IsValid)
         {
             return View(model);
         }
         var retVal = ServiceProvider.Instance().GetCustomerServices().AddCustomer(model);
         if (retVal < 1)
         {
             ModelState.AddModelError("message", "Unable to add Customer");
             return View(model);
         }
         return RedirectToAction("CustomerList");
     }
     catch
     {
         ModelState.AddModelError("message", "Process Error Occurred!");
         return View(model);
     }
 }
Example #2
0
 //
 // GET: /Customer/Details/5
 public PartialViewResult AddNewCustomer()
 {
     var customer = new CustomerContract();
     var countryList = ServiceProvider.Instance().GetCountryServices().GetCountries() ?? new List<CountryContract>();
     var stateList = ServiceProvider.Instance().GetStateServices().GetStates() ?? new List<StateContract>();
     customer.Countrys = new SelectList(countryList, "CountryId", "Name", 0);
     customer.States = new SelectList(stateList, "StateId", "Name", 0);
     return PartialView("AddNewCustomer", customer);
 }
Example #3
0
 public int AddCustomer(CustomerContract customer)
 {
     try
     {
         return _customerRepository.AddCustomer(customer);
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return 0;
     }
 }
Example #4
0
 public int AddCustomer(CustomerContract customer)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = CustomerContractMapper.Map<CustomerContract, Customer>(customer);
         if(myEntityObj == null)
         {return -2;}
         var processedCustomer =  _repository.Add(myEntityObj);
         _uoWork.SaveChanges();
         return  processedCustomer.CustomerId;
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return 0;
     }
 }
Example #5
0
 public bool UpdateCustomer(CustomerContract customer)
 {
     try
     {
         return _customerRepository.UpdateCustomer(customer);
         }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return false;
     }
 }
Example #6
0
 public ActionResult EditCustomerInfo(CustomerContract model)
 {
     try
     {
         var retVal = ServiceProvider.Instance().GetCustomerServices().UpdateCustomer(model);
         if (!retVal)
         {
             return PartialView("EditCustomer", model);
         }
         return RedirectToAction("CustomerList");
     }
     catch
     {
         return PartialView("EditCustomer", model);
     }
 }