Beispiel #1
0
        public ActionResult Create()
        {
            List <Business.Entities.owner> listOwner = RepoOwner.FindAll();

            CustomerFormStub formStub = new CustomerFormStub(listOwner);

            formStub.FillTypeOptions();
            formStub.FillTitleOptions();
            formStub.IdOwner = GetOwnerId();
            return(View("Form", formStub));
        }
Beispiel #2
0
        public ActionResult Edit(Guid id)
        {
            customer customer = RepoCustomer.FindByPk(id);
            List <Business.Entities.owner> listOwner = RepoOwner.FindAll();
            CustomerFormStub formStub = new CustomerFormStub(customer, listOwner);

            formStub.FillTypeOptions();
            formStub.FillTitleOptions();
            ViewBag.name = customer.name;
            return(View("Form", formStub));
        }
Beispiel #3
0
        public ActionResult Edit(CustomerFormStub model)
        {
            //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0;

            if (ModelState.IsValid)
            {
                customer dbItem = RepoCustomer.FindByPk(model.Id);
                dbItem = model.GetDbObject(dbItem);

                try
                {
                    RepoCustomer.Save(dbItem);
                }
                catch (Exception e)
                {
                    model.FillOwnerOptions(RepoOwner.FindAll());
                    model.FillTypeOptions();
                    model.FillTitleOptions();
                    return(View("Form", model));
                }

                //message
                string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString();
                this.SetMessage(model.Name, template);

                return(RedirectToAction("Index"));
            }
            else
            {
                customer customer = RepoCustomer.FindByPk(model.Id);
                ViewBag.name = customer.name;
                model.FillOwnerOptions(RepoOwner.FindAll());
                model.FillTypeOptions();
                model.FillTitleOptions();
                return(View("Form", model));
            }
        }