コード例 #1
0
        public virtual ActionResult Save(CustomerLogoModel customerModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", customerModel));
            }
            if (customerModel.CustomerLogoId <= 0) //Create News
            {
                var customer = new CustomerLogo()
                {
                    CustomerName = customerModel.CustomerName,
                    LogoUrl      = customerModel.LogoUrl,
                    HomePageUrl  = customerModel.HomePageUrl
                };
                using (UnitOfWork)
                {
                    Repository.Insert(customer);
                }
            }
            else //Edit user
            {
                var customer = Repository.GetById(customerModel.CustomerLogoId);
                customer.CustomerName = customerModel.CustomerName;
                customer.LogoUrl      = customerModel.LogoUrl;
                customer.HomePageUrl  = customerModel.HomePageUrl;
                using (UnitOfWork)
                {
                    Repository.Update(customer);
                }
            }

            //Save success
            SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Logo khách hàng"));
            return(RedirectToAction("Index", new { area = "Administrator" }));
        }
コード例 #2
0
        public virtual ActionResult Edit(int id)
        {
            var entity = Repository.GetById(id);
            var model  = new CustomerLogoModel()
            {
                CustomerLogoId = entity.CustomerLogoId,
                CustomerName   = entity.CustomerName,
                LogoUrl        = entity.LogoUrl,
                HomePageUrl    = entity.HomePageUrl
            };

            return(View("Edit", model));
        }
コード例 #3
0
        public ActionResult Create()
        {
            var model = new CustomerLogoModel();

            return(View(model));
        }