Example #1
0
        public async Task <ActionResult> Create()
        {
            var user = await _userManager.GetUserAsync(User);

            var vm = new TitleCreateViewModel(_db, _userManager)
            {
                User = user,
                InitialLocationSelectList = GetLocListItemsForCounty(user.CountyId)
            };

            vm.Title.InitialLocation = vm.GetDefaultCountyLocation(_db).Id;
            return(View(vm));
        }
Example #2
0
        public async Task <ActionResult> Create(TitleCreateViewModel vm)
        {
            var user = await _userManager.GetUserAsync(User);

            vm._db  = _db;
            vm.User = user;
            vm.InitialLocationSelectList = GetLocListItemsForCounty(user.CountyId);
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }
            var id = vm.AddTitleAndSave(vm, _db);

            vm.AddTranferForNewTitleAndSave(id, _db, vm.Title.InitialLocation);
            return(RedirectToAction("Details", "Titles", new { id = vm.Title.Id }));
        }
Example #3
0
        public int AddTitleAndSave(TitleCreateViewModel vm, ApplicationDbContext db)
        {
            vm.Title.CountyId  = db.Counties.Find(User.CountyId).Id;
            vm.Title.UserId    = User.Id.ToString();
            vm.Title.CustFName = vm.Title.CustFName.ToUpper();
            if (vm.Title.CustFName2 != null)
            {
                vm.Title.CustFName2 = vm.Title.CustFName2.ToUpper();
            }
            if (vm.Title.CustFName3 != null)
            {
                vm.Title.CustFName3 = vm.Title.CustFName3.ToUpper();
            }
            vm.Title.CustLName = vm.Title.CustLName.ToUpper();
            if (vm.Title.CustLName2 != null)
            {
                vm.Title.CustLName2 = vm.Title.CustLName2.ToUpper();
            }
            if (vm.Title.CustLName3 != null)
            {
                vm.Title.CustLName3 = vm.Title.CustLName3.ToUpper();
            }
            vm.Title.CustAddr1 = vm.Title.CustAddr1.ToUpper();
            if (vm.Title.CustAddr2 != null)
            {
                vm.Title.CustAddr2 = vm.Title.CustAddr2.ToUpper();
            }
            vm.Title.CustCity  = vm.Title.CustCity.ToUpper();
            vm.Title.CustState = vm.Title.CustState.ToUpper();
            if (vm.Title.CustEmail != null)
            {
                vm.Title.CustEmail = vm.Title.CustEmail.ToLower();
            }
            vm.Title.Vin        = vm.Title.Vin.ToUpper();
            vm.Title.TitleState = vm.Title.TitleState.ToUpper();
            vm.Title.VehMake    = vm.Title.VehMake.ToUpper();
            vm.Title.VehModel   = vm.Title.VehModel.ToUpper();
            db.Titles.Add(vm.Title);
            db.SaveChanges();
            var id = vm.Title.Id;

            return(id);
        }