예제 #1
0
        public AccountModel AddContact(AccountModel account, ContactModel contact)
        {
            var accountGraph = AccountRepository.GetAccount(account.Id);
            accountGraph.AddContact(new Data.Graph.Contact()
            {
                ContactDetail = contact.ContactDetail,
                ContactType = AccountRepository.GetContactTypes().Where(t => t.Id == contact.ContactTypeId).First(),
                FirstName = contact.FirstName,
                LastName = contact.LastName
            });

            AccountRepository.SaveAccount(accountGraph);

            return Mapper.Map<Data.Graph.Account, AccountModel>(accountGraph);
        }
예제 #2
0
        public AccountModel CreateAccount(AccountModel account)
        {
            var graph = new Data.Graph.Account();
            graph.AccountType = AccountTypeRepository.GetAccountType(account.AccountTypeId);
            graph.AddressLine1 = account.AddressLine1;
            graph.AddressLine2 = account.AddressLine2;
            graph.City = account.City;
            graph.Name = account.Name;
            graph.Notes = account.Notes;
            graph.PostalCode = account.PostalCode;
            graph.StateCode = account.StateCode;

            AccountRepository.SaveAccount(graph);

            return Mapper.Map<Data.Graph.Account, AccountModel>(graph);
        }
예제 #3
0
        public ActionResult NewAccount(AccountFilterModel filter, FormCollection collection)
        {
            var account = new AccountModel();
            try
            {
                UpdateModel(account);
                AccountServices.CreateAccount(account);

                return RedirectToAction("AccountListing", filter.GenerateAccountListingRoute());
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                var model = new AccountDetailModel()
                {
                    Action = "NewAccount",
                    Account = account,
                    Filter = filter
                };

                ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false, account.AccountTypeId);
                ViewBag.StateCodes = LookupServices.GetStateOptions(account.StateCode);

                return View("AccountDetail", model);
            }
        }
예제 #4
0
        public AccountModel UpdateContact(AccountModel account, ContactModel contact)
        {
            var accountGraph = AccountRepository.GetAccount(account.Id);
            var contactGraph = accountGraph.ContactList.Where(c => c.Id == contact.Id).First();

            contactGraph.ContactDetail = contact.ContactDetail;
            contactGraph.ContactType = AccountRepository.GetContactTypes().Where(t => t.Id == contact.ContactTypeId).First();
            contactGraph.FirstName = contact.FirstName;
            contactGraph.LastName = contact.LastName;

            AccountRepository.SaveAccount(accountGraph);

            return Mapper.Map<Data.Graph.Account, AccountModel>(accountGraph);
        }