public async Task <int> AddGenericPage(GenericPageDto genDto, CancellationToken cancellationToken) { var model = _mapper.Map <GenericPage>(genDto); model.CreatedBy = genDto.CreatedBy; model.ModifiedBy = genDto.CreatedBy; await _repo.AddGenericPage(model, cancellationToken).ConfigureAwait(false); return(1); }
public async Task <int> UpdateGenericPage(int id, GenericPageDto genDto, CancellationToken cancellationToken) { int ReturnId = 0; var model = await _repo.GetGenericPageById(id, cancellationToken); if (model != null) { _mapper.Map(genDto, model); model.ModifiedBy = genDto.CreatedBy; model.ModifiedDate = DateTime.Now; await _repo.UpdateGenericPage(model, cancellationToken).ConfigureAwait(false); ReturnId = 1; } return(ReturnId); }
public async Task <IActionResult> UpdateGenericPage(int id, GenericPageDto gen, CancellationToken cancellationToken) { try { int result = await _genService.UpdateGenericPage(id, gen, cancellationToken).ConfigureAwait(false); if (result == 0) { return(BadRequest()); } else { return(Ok("Page Updated Successfully")); } } catch (Exception ex) { await _errorlogService.InsertError(Request.GetDisplayUrl(), ControllerContext.ActionDescriptor.ActionName.ToString(), ex.Message, ex.ToString()).ConfigureAwait(false); return(StatusCode(500, ex.InnerException)); } }