public async Task <AppAddress> AddAsync(AppAddress data) { _repository.AppAddresses.Add(data); await _repository.SaveChangesAsync(); return(data); }
public async Task <AppAddress> UpdateAsync(AppAddress data) { var item = _repository.AppAddresses.Attach(data); item.State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _repository.SaveChangesAsync(); return(data); }
public async Task <AppAddress> DeleteAsync(int id) { AppAddress item = await _repository.AppAddresses.FindAsync(id); if (item != null) { _repository.AppAddresses.Remove(item); await _repository.SaveChangesAsync(); } return(item); }
public async Task <IActionResult> CreateAppAddressData(AppAddressCreateViewModel model) { if (ModelState.IsValid) { string uniquePictureFileName = ProcessUploadAppAddressImage(model); var newAppAddress = new AppAddress { Address = model.Address, Picture = uniquePictureFileName, Phone = model.Phone, City = model.City, Description = model.Description, Email = model.Email }; await _addressRepository.AddAsync(newAppAddress); TempData["message"] = $"Address {model.Address} was created."; return(RedirectToAction("AddressList")); } return(View()); }