public bool Update(UpdateSiteDto updateSiteDto) { var dbSite = _context.Sites.Find(updateSiteDto.Id); dbSite = _mapper.Map <UpdateSiteDto, Site>(updateSiteDto, dbSite); _context.SaveChanges(); return(true); }
public async Task <IActionResult> Edit(UpdateSiteDto model) { if (ModelState.IsValid) { var response = await _siteService.Update(model); if (response.IsSuccess) { StatusMessage = SuccessNotifcation("Update site success!"); return(RedirectToAction("Index")); } ModelState.AddModelError("", response.Message); } return(View(model)); }
public async Task <IActionResult> PutAsync(int id, UpdateSiteDto updateSiteDto) { var existingSite = await _siteRepository.GetByIDAsync(id); if (existingSite == null) { return(NotFound()); } existingSite.CustomerCID = updateSiteDto.CustomerCID; existingSite.SiteName = updateSiteDto.SiteName; existingSite.Distance = updateSiteDto.Distance; await _siteRepository.UpdateAsync(existingSite); await _publishEndpoint.Publish(new SiteUpdated( existingSite.SiteID, existingSite.CustomerCID, existingSite.SiteName, existingSite.Distance )); return(NoContent()); }
public async Task <IActionResult> Update(UpdateSiteDto dto) { await Task.Run(() => _siteService.Update(dto)); return(Ok()); }