public ActionResult Create(CompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                var company = new BOCompany();
                Mapper.Map<CompanyViewModel, BOCompany>(model, company);
                Mapper.Map<CompanyViewModel, BOAddress>(model, company.ShippingAddress);

                if (_companyService.CompanyNameExists(company))
                {
                    List<KeyValuePair<long, string>> statesdata = _stateProvinceService.GetAll();
                    model.StateList = new SelectList(statesdata, SelectLists.DataValueField, SelectLists.DataTextField, model.State);
                    model.Message = "A Company already exists with this name";
                    return View(model);
                }

                _companyService.Save(company);

                return RedirectToAction("Index");
            }

            List<KeyValuePair<long, string>> states = _stateProvinceService.GetAll();
            model.StateList = new SelectList(states, SelectLists.DataValueField, SelectLists.DataTextField, model.State);

            return View(model);
        }
        public ActionResult Create()
        {
            List<KeyValuePair<long, string>> states = _stateProvinceService.GetAll();

            var model = new CompanyViewModel()
            {
                StateList = new SelectList(states, SelectLists.DataValueField, SelectLists.DataTextField, SelectLists.UnitializedSelectValue)
            };

            return View(model);
        }
 public ActionResult EditProperties(CompanyViewModel model)
 {
     return PartialView("Object", model);
 }
        public ActionResult Edit(CompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                BOCompany company = _companyService.GetCompanyById(model.CompanyID);
                Mapper.Map<CompanyViewModel, BOCompany>(model, company);
                Mapper.Map<CompanyViewModel, BOAddress>(model, company.ShippingAddress);

                _companyService.Save(company);

                return RedirectToAction("Index");
            }

            List<KeyValuePair<long, string>> states = _stateProvinceService.GetAll();
            model.StateList = new SelectList(states, SelectLists.DataValueField, SelectLists.DataTextField, model.State);

            return View(model);
        }