public RestMessage <bool> Put(string collection, string id, [FromBody] JObject value) { RestMessage <bool> response = new RestMessage <bool>(false); try { value["_id"] = id; service.Update(collection, value, true); response.Data = true; return(response); } catch (ValidationException err) { response.Errors = err.Errors; } catch (Exception untrapped) { //TODO: log here response.Errors.Add(new Library.Core.Error() { Code = "UNEXPEXTED", Title = $"{collection} produces an unexpexted error", Description = untrapped.Message, }); } return(response); }
public override void Execute(string collection, ref JObject item, ref Dictionary <string, object> dataContext) { if (collection == "_users") { if (dataContext.ContainsKey("NewPassword")) { string id = item["_id"].Value <string>(); JObject o = new JObject { ["UserId"] = id, ["PasswordHash"] = RawUserStore.ComputePasswordHash(dataContext["NewPassword"] as string) }; //Password cant' be changed during update if (item.ContainsKey("_id") && !string.IsNullOrWhiteSpace(item["_id"].Value <string>())) { DataQuery query = new DataQuery() { RawQuery = JsonConvert.SerializeObject(new { UserId = id }) }; ItemList password = service.Query(collection, query); if (password.Items.HasValues) { o["_id"] = password.Items[0]["_id"].Value <string>(); //patch password only service.Update("_credentials", o, false); } else { service.Insert("_credentials", o); } } else { service.Insert("_credentials", o); } } } }
public async Task <Account> Update(int id, Account UpdatedEntity) { return(await _CRUDService.Update(id, UpdatedEntity)); }
public async Task <IdentityResult> UpdateAsync(IdentityUser user, CancellationToken cancellationToken) { service.Update(collection, JObject.FromObject(user), true); return(IdentityResult.Success); }
public async Task <F> Update(int id, F UpdatedEntity) { return(await _CRUDService.Update(id, UpdatedEntity)); }