public async Task <int> RemoveObjPromotionContent(PromotionContent model) { db.PromotionContents.Remove(model); await db.SaveChangesAsync(); return((int)EnumCore.Result.action_true); }
public async Task <int> CreatePromotionContent(PromotionContent ObjPromotionContent) { try { db.PromotionContents.Add(ObjPromotionContent); return(await db.SaveChangesAsync()); } catch (Exception e) { return((int)EnumCore.Result.action_false); } }
public async Task <ActionResult> Delete(long PromotionId, long ProductId) { PromotionContent Mainmodel = cms_db.GetObjPromotionContentById(PromotionId); if (Mainmodel.CrtdUID == (long.Parse(User.Identity.GetUserId()))) { ; } await cms_db.RemoveObjPromotionContent(Mainmodel); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(PromotionContentViewModel model) { int _tmp = cms_db.GetlstPromotionContent(model.MainContentId, null, model.ObjType, model.PromotionType, null).Count(); if (_tmp > 0) { return(RedirectToAction("Create", new { pro_id = model.MainContentId })); } if (model.PromotionProductId != null && model.PromotionProductId.Count() > 0) { foreach (long item in model.PromotionProductId) { PromotionContent Mainmodel = new PromotionContent(); Mainmodel.MainContentId = model.MainContentId; Mainmodel.MainContentName = cms_db.GetlstProduct().Where(s => s.ProductId == Mainmodel.MainContentId).FirstOrDefault().ProductName; Mainmodel.PromotionType = model.PromotionType; Mainmodel.PromotionTypeName = cms_db.GetNameObjClasscifiById(model.PromotionType); Mainmodel.CrtdUID = long.Parse(User.Identity.GetUserId()); Mainmodel.CrtdName = User.Identity.GetUserName(); Mainmodel.CrtdDT = DateTime.Now; Mainmodel.ObjType = model.ObjType; Mainmodel.ObjTypeName = cms_db.GetNameObjClasscifiById(model.ObjType); Mainmodel.MainCateId = cms_db.GetlstProduct().Where(s => s.ProductId == Mainmodel.MainContentId).FirstOrDefault().CategoryId; Mainmodel.MainCatetName = cms_db.GetlstProduct().Where(s => s.ProductId == Mainmodel.MainContentId).FirstOrDefault().CategoryName; Mainmodel.StartDT = this.SpritDateTime(model.DateTimeTxt)[0]; Mainmodel.EndDT = this.SpritDateTime(model.DateTimeTxt)[1]; Mainmodel.SubContentId = item; Mainmodel.MainCatetName = cms_db.GetlstProduct().Where(s => s.ProductId == item).FirstOrDefault().CategoryName; await cms_db.CreatePromotionContent(Mainmodel); } } else { PromotionContent Mainmodel = new PromotionContent(); Mainmodel.MainContentId = model.MainContentId; Mainmodel.MainContentName = cms_db.GetlstProduct().Where(s => s.ProductId == Mainmodel.MainContentId).FirstOrDefault().ProductName; Mainmodel.PromotionType = model.PromotionType; Mainmodel.PromotionTypeName = cms_db.GetNameObjClasscifiById(model.PromotionType); Mainmodel.CrtdUID = long.Parse(User.Identity.GetUserId()); Mainmodel.CrtdName = User.Identity.GetUserName(); Mainmodel.CrtdDT = DateTime.Now; Mainmodel.ObjType = model.ObjType; Mainmodel.ObjTypeName = cms_db.GetNameObjClasscifiById(model.ObjType); Mainmodel.MainCateId = cms_db.GetlstProduct().Where(s => s.ProductId == Mainmodel.MainContentId).FirstOrDefault().CategoryId; Mainmodel.MainCatetName = cms_db.GetlstProduct().Where(s => s.ProductId == Mainmodel.MainContentId).FirstOrDefault().CategoryName; Mainmodel.StartDT = this.SpritDateTime(model.DateTimeTxt)[0]; Mainmodel.EndDT = this.SpritDateTime(model.DateTimeTxt)[1]; await cms_db.CreatePromotionContent(Mainmodel); } return(RedirectToAction("Create", new { pro_id = model.MainContentId })); }
public PromotionContent GetObjPromotionContentById(long id) { PromotionContent Obj = db.PromotionContents.Find(id); return(Obj); }
public PromotionContentViewModel(PromotionContent model) { _MainObj = model; }
public PromotionContentViewModel() { _MainObj = new PromotionContent(); }