Esempio n. 1
0
        public ActionResult EditCreditAccount(int?id)
        {
            var creditAccount = _businessAccountService.GetById(id.Value);
            var model         = GetModelForNewCreditAccount(creditAccount);

            return(View("NewCreditAccount", model));
        }
Esempio n. 2
0
        public ActionResult New(CompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                Mapper.CreateMap <CompanyViewModel, BusinessAccount>();
                BusinessAccount company = Mapper.Map <CompanyViewModel, BusinessAccount>(model);

                if (model.Id == 0)
                {
                    company.HotelId          = HotelID;
                    company.CompanyTelephone = company.Telephone;
                    company.CompanyAddress   = company.CompanyAddress;
                    company.Status           = "LIVE";
                    company.Debtor           = false;
                    company.AccountTypeId    = 1;
                    _businessAccountService.Create(company);
                }
                else
                {
                    var existingCompany = _businessAccountService.GetById(model.Id);
                    existingCompany.Email            = model.Email;
                    existingCompany.Name             = model.Name;
                    existingCompany.ContactName      = model.ContactName;
                    existingCompany.Address          = model.Address;
                    existingCompany.CompanyAddress   = model.CompanyAddress;
                    existingCompany.CompanyName      = model.CompanyName;
                    existingCompany.CompanyTelephone = model.CompanyTelephone;
                    existingCompany.ContactName      = model.ContactName;
                    existingCompany.ContactNumber    = model.ContactNumber;
                    existingCompany.NatureOfBusiness = model.NatureOfBusiness;
                    existingCompany.Telephone        = model.Telephone;
                    existingCompany.Mobile           = model.Mobile;

                    _businessAccountService.Update(existingCompany);
                }

                return(RedirectToAction("Edit", new { id = company.Id, itemSaved = true }));
            }


            return(View(model));
        }
        public ActionResult New(CompanyViewModel model)
        {
            //SearchFor Existing NameValueCollectionExtensions

            var alreadyCreated = _businessAccountService.GetAll(1).FirstOrDefault(x => x.Name.ToUpper().Equals(model.Name.ToUpper()));

            if (model.Id == 0)
            {
                if (alreadyCreated != null)
                {
                    ModelState.AddModelError("_FORM", "This Account name already exists. Please reenter account name");
                }
            }
            else
            {
                if (alreadyCreated != null && alreadyCreated.Id != model.Id)
                {
                    ModelState.AddModelError("_FORM", "This Account name already exists. Please reenter account name");
                }
            }



            if (ModelState.IsValid)
            {
                Mapper.CreateMap <CompanyViewModel, BusinessAccount>();
                BusinessAccount company = Mapper.Map <CompanyViewModel, BusinessAccount>(model);

                if (model.Id == 0)
                {
                    company.HotelId          = HotelID;
                    company.CompanyTelephone = company.Telephone;
                    company.CompanyAddress   = company.CompanyAddress;
                    company.Status           = "LIVE";
                    company.Debtor           = false;
                    _businessAccountService.Create(company);
                }
                else
                {
                    var existingCompany = _businessAccountService.GetById(model.Id);
                    existingCompany.Email            = model.Email;
                    existingCompany.Name             = model.Name;
                    existingCompany.ContactName      = model.ContactName;
                    existingCompany.Address          = model.Address;
                    existingCompany.CompanyAddress   = model.CompanyAddress;
                    existingCompany.CompanyName      = model.CompanyName;
                    existingCompany.CompanyTelephone = model.CompanyTelephone;
                    existingCompany.ContactName      = model.ContactName;
                    existingCompany.ContactNumber    = model.ContactNumber;
                    existingCompany.NatureOfBusiness = model.NatureOfBusiness;
                    existingCompany.Telephone        = model.Telephone;
                    existingCompany.Mobile           = model.Mobile;

                    _businessAccountService.Update(existingCompany);
                }

                return(RedirectToAction("Edit", new { id = company.Id, itemSaved = true }));
            }


            return(View(model));
        }