public JsonResult Delete(ma_articoli model) { DbObject obj = new DbObject(); try { var _obj = db.ma_articoli.Find(model.id_articolo); db.ma_articoli.Remove(_obj); db.SaveChanges(); obj.db_obj_ack = "OK"; } catch (Exception ex) { obj.db_obj_ack = "KO"; obj.db_obj_message = ex.Message; } return(Json(obj, JsonRequestBehavior.AllowGet)); }
public ActionResult Advertisement() { ma_articoli articoli = db.ma_articoli .Where(x => x.online == true & x.venduto == false) .OrderBy(x => Guid.NewGuid()) .Take(1) .FirstOrDefault(); FeaturedModelView model = new FeaturedModelView(); if (articoli != null) { model.articolo = articoli.articolo; model.id_articolo = articoli.id_articolo; model.img = CommonHelper.getImgArt(articoli, Url.Content("~/public/media/ads/")); } return(PartialView("~/Views/Category/_Advertisement.cshtml", model)); }
public JsonResult Create(ma_articoli model) { DbObject obj = new DbObject(); obj.db_obj_ack = "KO"; obj.db_obj_message = "Attenzione i campi obbligatori non sono stati validati"; if (ModelState.IsValid) { try { db.ma_articoli.Add(model); db.SaveChanges(); obj.db_obj_ack = "OK"; } catch (Exception ex) { obj.db_obj_ack = "KO"; obj.db_obj_message = ex.Message; } } return(Json(obj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="url"></param> /// <returns></returns> internal static string getImgArt(ma_articoli x, string url) { var model = x.ma_articoli_img.FirstOrDefault().id_img_articolo; return(model != null ? url + "/" + model : url + "/" + "no_img.jpg"); }