Esempio n. 1
0
        public ActionResult NewCreditAccount(CreditAccountViewModel model)
        {
            if (ModelState.IsValid)
            {
                Mapper.CreateMap <CreditAccountViewModel, BusinessAccount>();
                var creditAccount = Mapper.Map <CreditAccountViewModel, BusinessAccount>(model);
                creditAccount.Status = "LIVE";

                if (creditAccount.Id > 0)
                {
                    var existingAccount = _businessAccountService.GetById(creditAccount.Id);
                    existingAccount.Address          = creditAccount.Address;
                    existingAccount.CompanyAddress   = creditAccount.CompanyAddress;
                    existingAccount.CompanyName      = creditAccount.CompanyName;
                    existingAccount.CompanyTelephone = creditAccount.CompanyTelephone;
                    existingAccount.ContactName      = creditAccount.ContactName;
                    existingAccount.ContactNumber    = creditAccount.ContactNumber;
                    existingAccount.Email            = creditAccount.Email;
                    existingAccount.Mobile           = creditAccount.Mobile;
                    existingAccount.Name             = creditAccount.Name;
                    existingAccount.NatureOfBusiness = creditAccount.NatureOfBusiness;
                    existingAccount.Telephone        = creditAccount.Telephone;
                    _businessAccountService.Update(existingAccount);
                }
                else
                {
                    creditAccount.Debtor = false;
                    _businessAccountService.Create(creditAccount);
                }

                return(RedirectToAction("Booking", "Home"));
            }

            return(View(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));
        }