public HttpResponseMessage Update([FromBody] AccountView inst) { var t = new AccountValidationAttribute(); if (!(t.IsValid(inst))) { var resp = Request.CreateErrorResponse(HttpStatusCode.BadRequest, t.ErrorMessage); return(resp); } else { accountService.Update(inst.AccountFromViewToDomain()); HttpResponseMessage response = Request.CreateResponse <string>(HttpStatusCode.OK, "Account успешно обновлен!!"); return(response); } }
public HttpResponseMessage Get([FromUri] int id) { var temp = accountService.Get(id).AccountFromDomainToView(); var t = new AccountValidationAttribute(); if (!(t.IsValid(temp))) { var resp = Request.CreateErrorResponse(HttpStatusCode.NotFound, t.ErrorMessage.ToString()); return(resp); } else { HttpResponseMessage response = Request.CreateResponse <AccountView>(HttpStatusCode.OK, temp); return(response); } }
public HttpResponseMessage Delete([FromUri] int id) { var temp = accountService.Get(id).AccountFromDomainToView(); var t = new AccountValidationAttribute(); if (!(t.IsValid(temp))) { var resp = Request.CreateErrorResponse(HttpStatusCode.NotFound, t.ErrorMessage); return(resp); } else { accountService.Delete(id); HttpResponseMessage response = Request.CreateResponse <string>(HttpStatusCode.OK, "Account успешно удален!!"); return(response); } }