public async Task <IActionResult> UpdateType([FromBody] UpdateTypeRequest request) { Type type = await _typeService.GetById(request.Id); type.Name = request.Name; _typeService.Update(type); return(Ok()); }
public UpdateTypeResponse Update(UpdateTypeRequest request) { var response = new UpdateTypeResponse(); try { var type = request.MapTo <Data.Entities.Type>(); DataContext.Types.Attach(type); DataContext.Entry(type).State = EntityState.Modified; DataContext.SaveChanges(); response.IsSuccess = true; response.Message = "KPI Type item has been updated successfully"; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return(response); }
public override Task <Reply> UpdateType(UpdateTypeRequest request, ServerCallContext context) { return(UpdateFields(request.Id, context, async user => { if (request.UserType == Users.User.Types.Type.Adm) { return Error.InvalidOperation; } if (request.UserType == Users.User.Types.Type.Normal) { user.Authorised = 0; await _userService.ClearUser(request.Id); } else if (request.UserType == Users.User.Types.Type.Authorised) { user.Authorised = 1; await _userService.ClearUser(request.Id); } return Error.None; })); }