public HttpResponseMessage Detail(IdModelCategoriaUnidad Id) { CategoriaUnidad acu = new CategoriaUnidad(); try { acu = db.CategoriaUnidad.Where(x => x.IdCategoriaUnidad == Id.IdCategoriaUnidad).FirstOrDefault(); if (acu != null) { return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(acu), System.Text.Encoding.UTF8, "application/json") } } ; else { return new HttpResponseMessage(System.Net.HttpStatusCode.NoContent) { Content = null } }; } catch (Exception ex) { return(Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message + Environment.NewLine + "CategoriaUnidad")); } }
public HttpResponseMessage Delete(IdModelCategoriaUnidad Id) { CategoriaUnidad acu = new CategoriaUnidad(); try { acu = db.CategoriaUnidad.Where(x => x.IdCategoriaUnidad == Id.IdCategoriaUnidad).FirstOrDefault(); if (acu != null) { acu.Activo_Inactivo = false; db.SaveChanges(); return(new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = null }); } else { return(new HttpResponseMessage(System.Net.HttpStatusCode.NoContent) { Content = null }); } } catch (Exception ex) { return(Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message + Environment.NewLine + "CategoriaUnidad")); } }