public IHttpActionResult DeleteById(int id) { HttpStatusCode response = SastojciHelper.DeleteById(id); if (response == HttpStatusCode.NotFound) { return(NotFound()); } return(Ok()); }
public HttpResponseMessage Sastojci(SastojciPostWithImage ns) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } HttpStatusCode response = SastojciHelper.AddSastojci(ns); if (HttpStatusCode.Conflict == response) { return(Request.CreateResponse(HttpStatusCode.Conflict, ns)); } return(Request.CreateResponse(HttpStatusCode.OK, ns)); }
public HttpResponseMessage GetListOmiljeni(string vrstasastojka = "") { List <Sastojci> listSastojci = SastojciHelper.GetOmiljeni(vrstasastojka); List <OmiljeniSastojci> sastojci = new List <OmiljeniSastojci>(); foreach (Sastojci item in listSastojci) { OmiljeniSastojci tmp = new OmiljeniSastojci(); tmp.SastojakId = item.Id; tmp.Naziv = item.Naziv; byte[] slikaSastojka = _ctx.Slike.Where(slika => slika.SastojakId == item.Id).Select(x => x.Slika).FirstOrDefault(); if (slikaSastojka != null) { tmp.SlikaThumb = slikaSastojka; } sastojci.Add(tmp); } return(Request.CreateResponse(HttpStatusCode.OK, sastojci)); }
public HttpResponseMessage GetSastojci(string naziv = "") { List <SastojciPregledVm> response = SastojciHelper.GetSastojci(naziv); return(Request.CreateResponse(HttpStatusCode.OK, response)); }