public GargoyleEntity(GargoyleModel model) { this.Name = model.Name; this.Color = model.Color; this.Size = model.Size; this.Gender = model.Gender; this.Updated = model.Updated; }
public IActionResult Patch(string index, [FromBody] GargoyleModel gargoyleModel) { var model = this.gargoylesDatabase.Get(index); if (gargoyleModel.Color != null) { model.Color = gargoyleModel.Color; } // also, convert to an entity first return(Json(model)); }
public void Update(GargoyleModel model) { var modelToUpdate = this.gargoyles[model.Name]; // true if null // true if "" // true if " " if (!string.IsNullOrWhiteSpace(model.Color)) { modelToUpdate.Updated = DateTime.UtcNow; modelToUpdate.Color = model.Color; } }
public GargoyleModel Update(string index, GargoyleModel model) { var modelToUpdate = this.gargoyles[index]; // true if null // true if "" // true if " " if (!string.IsNullOrWhiteSpace(model.Color)) { modelToUpdate.Updated = DateTime.UtcNow; modelToUpdate.Color = model.Color; } return(modelToUpdate); }
public IActionResult Put(string index, [FromBody] GargoyleModel gargoyleModel) { // we aren't doing index checking for the lecture. don't forget it if (!Request.Headers.TryGetValue("If-Match", out StringValues ifMatch)) { return(StatusCode((int)HttpStatusCode.PreconditionFailed)); } var model = this.gargoylesDatabase.Get(index); if (model.ETag() != ifMatch) { return(StatusCode((int)HttpStatusCode.PreconditionFailed)); } this.gargoylesDatabase.AddOrReplace(gargoyleModel); // also, convert to an entity first return(Json(model)); }
public void AddOrReplace(GargoyleModel model) { model.Updated = DateTime.UtcNow; this.gargoyles[model.Name] = model; }
public GargoyleEntity(GargoyleModel model) { this.Name = model.Name; this.Color = model.Color; }