public async Task <IActionResult> Create([FromBody] SaveBNKSEEKResource newRecord) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newRecord == null) { return(BadRequest()); } // TODO Make a catch exception if apiResources is NULL // ? Trim trailing spaces from char fields // ? url: https://community.dynamics.com/gp/b/gpdynland/archive/2017/06/10/asp-net-core-and-ef-core-with-dynamics-gp-trim-trailing-spaces-from-char-fields newRecord = TrimStrings.TrimProps <SaveBNKSEEKResource>(newRecord); var created = mapper.Map <SaveBNKSEEKResource, BNKSEEKEntity>(newRecord); created.DT_IZM = DateTime.Today; // ? Save changes to the DB repository.AddAsync(created); await unitOfWork.CompleteAsync(); return(Ok(newRecord)); }
public async Task <IActionResult> Update(string vkey, [FromBody] SaveBNKSEEKResource record) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (record == null) { return(BadRequest()); } // TODO Make a catch exception if apiResources is NULL // ? Trim trailing spaces from char fields // ? url: https://community.dynamics.com/gp/b/gpdynland/archive/2017/06/10/asp-net-core-and-ef-core-with-dynamics-gp-trim-trailing-spaces-from-char-fields record = TrimStrings.TrimProps <SaveBNKSEEKResource>(record); var decodedVKEY = converter.Convert(vkey); var source = await repository.GetByVKEYAsync(decodedVKEY, true); var updated = mapper.Map <SaveBNKSEEKResource, BNKSEEKEntity>( source: record, destination: source ); updated.DT_IZM = DateTime.Today; // ? Save changes to the DB repository.Update(updated); await unitOfWork.CompleteAsync(); return(Ok(record)); }