public async Task <RepositoryResponse <Lib.ViewModels.MixPortalPageRoles.ReadViewModel> > Update( [FromBody] Lib.ViewModels.MixPortalPageRoles.ReadViewModel model) { var result = new RepositoryResponse <Lib.ViewModels.MixPortalPageRoles.ReadViewModel>() { IsSucceed = true, Data = model }; if (model != null) { if (model.IsActived) { model.CreatedBy = _mixIdentityHelper.GetClaim(User, MixClaims.Username); var saveResult = await model.SaveModelAsync(false); result.IsSucceed = saveResult.IsSucceed; if (!result.IsSucceed) { result.Exception = saveResult.Exception; result.Errors.AddRange(saveResult.Errors); } } else { var saveResult = await model.RemoveModelAsync(false); if (!result.IsSucceed) { result.Exception = saveResult.Exception; result.Errors.AddRange(saveResult.Errors); } } return(result); } return(new RepositoryResponse <Lib.ViewModels.MixPortalPageRoles.ReadViewModel>()); }
public async Task <RepositoryResponse <Lib.ViewModels.MixPortalPageRoles.ReadViewModel> > Update( [FromBody] Lib.ViewModels.MixPortalPageRoles.ReadViewModel model) { var result = new RepositoryResponse <Lib.ViewModels.MixPortalPageRoles.ReadViewModel>() { IsSucceed = true, Data = model }; if (model != null) { if (model.IsActived) { model.CreatedBy = User.Claims.FirstOrDefault(c => c.Type == "Username")?.Value; var saveResult = await model.SaveModelAsync(false); result.IsSucceed = saveResult.IsSucceed; if (!result.IsSucceed) { result.Exception = saveResult.Exception; result.Errors.AddRange(saveResult.Errors); } } else { var saveResult = await model.RemoveModelAsync(false); if (!result.IsSucceed) { result.Exception = saveResult.Exception; result.Errors.AddRange(saveResult.Errors); } } return(result); } return(new RepositoryResponse <Lib.ViewModels.MixPortalPageRoles.ReadViewModel>()); }