Exemple #1
0
        public ActionResult Update(Customer customer)
        {
            try
            {
                var aCustomer = _customer.GetCustomerById(customer.Code);
                if (aCustomer != null)
                {
                    aCustomer.Name          = customer.Name;
                    aCustomer.Code          = customer.Code;
                    aCustomer.Address       = customer.Address;
                    aCustomer.Email         = customer.Email;
                    aCustomer.Contact       = customer.Contact;
                    aCustomer.LoyalityPoint = customer.LoyalityPoint;

                    var isUpdate = _customer.Update(aCustomer);
                    if (isUpdate)
                    {
                        ViewBag.SUpdate = "Update Success.";
                    }
                    else
                    {
                        ViewBag.FUpdate = "Update Failed.";
                    }
                }
                else
                {
                    ViewBag.FMsg = "Customer not found.";
                }
            }
            catch (Exception exception)
            {
                ViewBag.FMsg = exception.Message;
            }
            return(View());
        }