[Authorize(Roles = "Manager")] //פילטר של הרשאו public HttpResponseMessage Post([FromBody] CarModel value) { bool InsertResult = false; if (ModelState.IsValid) { InsertResult = CarManager.AddNewCar(value); } HttpStatusCode ResponsCode = InsertResult ? HttpStatusCode.Created : HttpStatusCode.BadRequest; return(new HttpResponseMessage(ResponsCode) { Content = new ObjectContent <bool>(InsertResult, new JsonMediaTypeFormatter()) }); }
public ActionResult Update(Car car) { bool result = false; car.Owner = (string)Session["UserId"]; result = CarManager.AddNewCar(car); if (result) { ViewBag.message = "Transaction Completed"; } else { ViewBag.message = "Transaction Failed"; } Car[] cars = CarManager.GetAllCars(); return(View("CarLister", cars)); // returns /Views/Pet/Listing.cshtml }