예제 #1
0
        public async Task <int> RemoveObjPromotionContent(PromotionContent model)
        {
            db.PromotionContents.Remove(model);
            await db.SaveChangesAsync();

            return((int)EnumCore.Result.action_true);
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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"));
        }
예제 #4
0
        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 }));
        }
예제 #5
0
        public PromotionContent GetObjPromotionContentById(long id)
        {
            PromotionContent Obj = db.PromotionContents.Find(id);

            return(Obj);
        }
예제 #6
0
 public PromotionContentViewModel(PromotionContent model)
 {
     _MainObj = model;
 }
예제 #7
0
 public PromotionContentViewModel()
 {
     _MainObj = new PromotionContent();
 }