Exemplo n.º 1
0
 public ActionResult Post(Rental rental)
 {
     var newEntity = repo.Add(rental);    // Create entity in DB
     if (newEntity == null)
     {
         return new HttpStatusCodeResult(422); // Unprocessable Entity -> Validation Error
     }
     this.logService.Insert(String.Format("New Rental Object generated with ID: {0}", newEntity.Id), "Information");
     return Created(String.Format("{0}{1}", Request.GetUri(), newEntity.Id), newEntity); // Return OK Header with Entity Location
 }
Exemplo n.º 2
0
        public HttpStatusCodeResult Put(Guid id, Rental rental)
        {
            if (!repo.Update(id, rental))
            {
                this.logService.Insert(String.Format("Update for Rental Object {0} failed", id), "Warning");
                return new HttpStatusCodeResult(422); // Unprocessable Entity -> Validation Error
            }

            this.logService.Insert(String.Format("Rental Object {0} successfully updated", id), "Warning");

            return Ok();
        }