public ActionResult AddOwner() { AddOwnerViewModel viewModel = new AddOwnerViewModel(); viewModel.Name = ""; return(View(viewModel)); }
public async Task <IActionResult> Create(AddOwnerViewModel model) { if (ModelState.IsValid) { _ownerService.AddOwner(model, await GetActiveUserId()); return(RedirectToAction("Index")); } return(View(model)); }
public Owner(AddOwnerViewModel model, Guid userId) { OwnerId = Guid.NewGuid(); Name = model.Name; Phone = model.Phone; Email = model.Email; FacebookUrl = model.FacebookUrl; TwitterUrl = model.TwitterUrl; InstagramUrl = model.InstagramUrl; YoutubeUrl = model.YoutubeUrl; UserId = userId; }
public IActionResult Add(AddOwnerViewModel addOwnerViewModel) { if (ModelState.IsValid) { Owner newOwner = new Owner { Name = addOwnerViewModel.Name }; context.Owners.Add(newOwner); context.SaveChanges(); return(Redirect("/Owner")); } return(View(addOwnerViewModel)); }
public async Task <IActionResult> Edit(AddOwnerViewModel addOwnerViewModel) { var owner = context.Owners.SingleOrDefault((l) => l.ID == addOwnerViewModel.ID); if (owner == null) { return(NotFound()); } var viewModel = new AddOwnerViewModel(owner); return(View(viewModel)); }
public async Task <ActionResult> AddOwner(AddOwnerViewModel viewModel) { if (ModelState.IsValid) { Owner newOwner = new Owner(); ContactInfo newContactInfo = new ContactInfo(); Address newAddress = new Address(); newAddress.Address1 = viewModel.ContactInfo.Address.Address1; newAddress.Address2 = viewModel.ContactInfo.Address.Address2; newAddress.City = viewModel.ContactInfo.Address.City; newAddress.State = viewModel.ContactInfo.Address.State; newAddress.Zip = viewModel.ContactInfo.Address.Zip; newContactInfo.Address = newAddress; newContactInfo.Email = viewModel.ContactInfo.Email; newContactInfo.Phone1 = viewModel.ContactInfo.Phone1; newContactInfo.Phone2 = viewModel.ContactInfo.Phone2; newOwner.Name = viewModel.Name; newOwner.ContactInfo = newContactInfo; using (REMSDAL dal = new REMSDAL()) { dal.Owners.Add(newOwner); var result = await dal.SaveChangesAsync(); if (result > 0) { viewModel.ActionStatusMessageViewModel.StatusMessage = "Owner " + viewModel.Name + " added."; viewModel.Name = ""; return(View(viewModel)); } } } // If we got this far, something failed, redisplay form viewModel.Name = ""; viewModel.ActionStatusMessageViewModel.StatusMessage = "There was an issue processing your request."; return(View(viewModel)); }
public IActionResult Add() { AddOwnerViewModel addOwnerViewModel = new AddOwnerViewModel(); return(View(addOwnerViewModel)); }
public void AddOwner(AddOwnerViewModel owner, Guid userId) { _ownerRepository.Insert(new Owner(owner, userId)); }