public WidgetConfModel UpdateWidgetConf(int id, UserPublicModel currentUser, WidgetConfUpdateModel updateModel) { var target = _widgetConfRepository.GetWidgetConfById(id); var toPatch = target; if (toPatch == null || toPatch.UserId != currentUser.Id) { return(null); } toPatch.Conf = updateModel.Conf; toPatch.UpdatedAt = DateTimeOffset.Now; return(_widgetConfRepository.UpdateWidgetConf(target, toPatch) == 1 ? toPatch : null); }
public ActionResult <string> PatchWidgetConf(int id, [FromForm] WidgetConfUpdateModel newConf) { if (!ModelState.IsValid) { return(BadRequest()); } var currentUser = _userBusiness.GetCurrentUser(User); if (currentUser == null) { return(Unauthorized()); } var patchedConf = _widgetConfBusiness.UpdateWidgetConf(id, currentUser, newConf); if (patchedConf != null) { return(Ok(patchedConf)); } return(BadRequest()); }