/// <summary> /// 抢单 /// </summary> /// <param name="Name">分类名称</param> /// <returns>返回调用结果</returns> /// <para name="result">200 是成功其他失败</para> /// <para name="data">对象结果</para> /// <remarks> /// 2018-08-18 林建生 /// </remarks> public object AddSC(string Name) { using (EFDB db = new EFDB()) { Guid Gid = LCookie.GetShopGid(); var b = db.ShopClassify.Where(l => l.Name == Name && l.ShopGid == Gid).FirstOrDefault(); if (b == null) { b = new ShopClassify(); b.Gid = Guid.NewGuid(); b.AddTime = DateTime.Now; b.ShopGid = Gid; b.Name = Name; b.Sort = 1; b.Show = 1; db.ShopClassify.Add(b); if (db.SaveChanges() == 1) { return(new AjaxResult("添加分类成功")); } else { return(new AjaxResult(300, "添加分类失败")); } } else { return(new AjaxResult(300, "分类名称已存在")); } } }
public JsonResult DFHSQ(Guid ProductGid) { Guid ShopGid = LCookie.GetShopGid(); if (ShopGid == Guid.Parse("00000000-0000-0000-0000-000000000000")) { return(Json(new AjaxResult(300, "请先申请商家!"))); } else { using (EFDB db = new EFDB()) { int State = db.Shop.Where(l => l.Gid == ShopGid).FirstOrDefault().State; if (State == 1) { return(Json(new AjaxResult(301, "商家还在审核阶段"))); } else { int c = db.ShopClassify.Where(l => l.ShopGid == ShopGid).Count(); if (c == 0) { return(Json(new AjaxResult(302, "请先添加商家分类之后再来申请"))); } else { var d = db.DFH.Where(l => l.ShopGid == ShopGid && l.ProductGid == ProductGid).FirstOrDefault(); if (d == null) { var b = new DFH(); b.Gid = Guid.NewGuid(); b.AddTime = DateTime.Now; b.ShopGid = ShopGid; b.ProductGid = ProductGid; b.State = 1; db.DFH.Add(b); return(Json(new AjaxResult(db.SaveChanges()))); } else { return(Json(new AjaxResult(d.State == 1 ? "正在审核中" : "已申请发布过了"))); } } } } } }