public HttpResponseMessage Delete(int lotId, [FromBody] string userCredentials) { var loginPass = userCredentials.Split(); if (loginPass.Length != 2) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad user credentials.")); } try { var mapper = MapperDTO.Mapper; var lot = mapper.Map <Lot, Services.Model.Lot> (new Lot { LotId = lotId }); var user = mapper.Map <User, Services.Model.User> (new User { Login = loginPass[0], Password = loginPass[1] }); Service.Delete(lot, user); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (InvalidOperationException exc) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exc.Message)); } }
public ActionResult Delete(int?id) { var lot = lotService.GetById(id.Value); lotService.Delete(lot); return(RedirectToAction("Index", "Home")); }