//Post a Tool /// <summary> /// Post a new Tool object to the Database /// </summary> /// <param name="Tool">Contains the required fields for a new Tool object</param> /// <returns></returns> public IHttpActionResult Post(ToolCreate Tool) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateToolService(); if (!service.CreateTool(Tool)) { return(InternalServerError()); } return(Ok()); }
// // Tool methods // public bool CreateTool(ToolCreate model) { using (var ctx = new ApplicationDbContext()) { var entity = new Tool() { OwnerID = model.OwnerID, HourlyRate = model.HourlyRate, DailyRate = model.DailyRate, ToolCondition = model.ToolCondition, ToolCatalogItemID = model.ToolCatalogItemID, }; //entity.Owner.IsOwner = true; ctx.Tools.Add(entity); return(ctx.SaveChanges() == 1); } }