public async Task <IActionResult> Edit(int id, [Bind("Id,Country,State,City,District,Street,Number,ZipCode,Complement,CompanyId,Name")] AddressCompany addressCompany) { if (id != addressCompany.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(addressCompany); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressCompanyExists(addressCompany.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", addressCompany.CompanyId); return(View(addressCompany)); }
public static bool UpdatePhoneCompanyScopeIsValid(this AddressCompany category, UpdateAddressCompanyCommand command) { return(AssertionConcern.IsSatisfiedBy ( AssertionConcern.AssertNotEmpty(command.Cep, "A Cep é obrigatória"), AssertionConcern.AssertNotEmpty(command.Number, "O Número é obrigatório") )); }
public async Task <IActionResult> Create([Bind("Id,Country,State,City,District,Street,Number,ZipCode,Complement,CompanyId,Name")] AddressCompany addressCompany) { if (ModelState.IsValid) { _context.Add(addressCompany); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", addressCompany.CompanyId); return(View(addressCompany)); }
/// <summary> /// This method returns a well formatted address string (HTML), based on the country /// </summary> /// <param name="includeName">Specifies whether potential address name information shall be included in the output string</param> /// <returns>Well formatted address string</returns> public string GetHtmlFormattedAddress(bool includeName = false) { // We need the country object to perform this operation using (var entCountry = NewCountryEntity()) { // Now, we can concatenate the appropriate string var address = string.Empty; if (includeName) { if (!string.IsNullOrEmpty(AddressCompany)) { address += "<b>" + AddressCompany.Trim() + "</b><br>"; } if (!string.IsNullOrEmpty(AddressName)) { address += "<b>" + AddressName.Trim() + "</b><br>"; } } address += Street.Trim() + "<br>"; if (!string.IsNullOrEmpty(Street2)) { address += Street2.Trim() + "<br>"; } if (!string.IsNullOrEmpty(Street3)) { address += Street3.Trim() + "<br>"; } switch (entCountry.AddressFormat) { case AddressFormat.CityStateZip: address += City.Trim() + ", " + State.Trim() + " " + Zip.Trim() + "<br>"; break; case AddressFormat.CityPostalCode: address += City.Trim() + ", " + Zip.Trim() + "<br>"; break; case AddressFormat.PostalCodeCity: address += Zip.Trim() + " " + City.Trim() + "<br>"; break; case AddressFormat.PostalCodeCityState: address += Zip.Trim() + " " + City.Trim() + ", " + State.Trim() + "<br>"; break; } address += entCountry.Name.Trim(); return(address); } }
public void Delete(AddressCompany address) { _context.AddressCompany.Remove(address); }
public void Update(AddressCompany address) { _context.Entry <AddressCompany>(address).State = System.Data.Entity.EntityState.Modified; }