Ejemplo n.º 1
0
        public bool UpdateDealStatus(int dealId)
        {
            //  Deals.CreatedDate = DateTime.Now;
            SA_Deals EditDeals = _context.SA_Deals.Where(Cat => Cat.id == dealId).FirstOrDefault();

            if (EditDeals.status.HasValue)
            {
                if (EditDeals.status.Value == 1)
                {
                    EditDeals.status = 2;
                }
                else
                {
                    EditDeals.status = 1;
                }
            }
            else
            {
                EditDeals.status = 1;
            }

            _context.Entry(EditDeals).State = EntityState.Modified;
            int x = _context.SaveChanges();

            return(x == 0 ? false : true);
        }
Ejemplo n.º 2
0
        public ActionResult SaveDeals(SA_Deals UserDeals)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName);
                    file.SaveAs(path);
                    UserDeals.DealsImg = fileName;
                }
            }
            UserDeals.CreatedTime = DateTime.Now;
            DealsDataStore Obj = new DealsDataStore();

            if (UserDeals.id == 0)
            {
                Obj.AddDeals(UserDeals);
            }
            else
            {
                Obj.EditDeals(UserDeals);
            }
            return(RedirectToAction("Deals"));
        }
Ejemplo n.º 3
0
        public async Task <bool> UpdateDeals(SA_Deals Deals)
        {
            _context.Entry(Deals).State = EntityState.Modified;
            //  Deals.ModeifiedDate = DateTime.Now;
            int x = await _context.SaveChangesAsync();

            return(x == 0 ? false : true);
        }
Ejemplo n.º 4
0
        public bool AddDeals(SA_Deals Deals)
        {
            //  Deals.CreatedDate = DateTime.Now;
            _context.SA_Deals.Add(Deals);
            int x = _context.SaveChanges();

            return(x == 0 ? false : true);
        }
Ejemplo n.º 5
0
        public ActionResult SaveDeals(SA_Deals UserDeals)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName);
                    file.SaveAs(path);
                    UserDeals.DealsImg = fileName;
                }
            }
            UserDeals.status      = 1;
            UserDeals.CreatedBy   = Session["User"].ToString();
            UserDeals.CreatedTime = UserDeals.CreatedTime != null? UserDeals.CreatedTime.Value: DateTime.Now;
            DealsDataStore Obj = new DealsDataStore();

            if (UserDeals.id == 0)
            {
                Obj.AddDeals(UserDeals);

                string np = Request.Form["allProduct"].ToString();

                foreach (string s in np.Split(','))
                {
                    if (s != "")
                    {
                        Obj.AddDealsProduct(new SA_DealsAndProductRelation
                        {
                            SA_DealID    = UserDeals.id,
                            SA_ProductId = Convert.ToInt16(s)
                        });
                    }
                }
            }
            else
            {
                Obj.EditDeals(UserDeals);

                string np = Request.Form["allProduct"].ToString();
                Obj.DeleteDealsProduct(UserDeals.id);
                foreach (string s in np.Split(','))
                {
                    if (s != "")
                    {
                        Obj.AddDealsProduct(new SA_DealsAndProductRelation
                        {
                            SA_DealID    = UserDeals.id,
                            SA_ProductId = Convert.ToInt16(s)
                        });
                    }
                }
            }
            return(RedirectToAction("Deals"));
        }
Ejemplo n.º 6
0
        public bool DeleteDeals(int DealsId)
        {
            //  Deals.CreatedDate = DateTime.Now;
            SA_Deals EditDeals = _context.SA_Deals.Where(Deals => Deals.id == DealsId).FirstOrDefault();

            _context.Entry(EditDeals).State = EntityState.Deleted;
            int x = _context.SaveChanges();

            return(x == 0 ? false : true);
        }
Ejemplo n.º 7
0
        public ActionResult EditDeals(int id)
        {
            DealsDataStore        Obj         = new DealsDataStore();
            SA_Deals              obj         = Obj.GetDealsByid(id);
            List <SelectListItem> productList = Obj.GetProductList();
            SA_DealsViewModel     objSaCatV   = new SA_DealsViewModel();

            objSaCatV.id               = obj.id;
            objSaCatV.DealsName        = obj.DealsName;
            objSaCatV.DealsDiscription = obj.DealsDiscription;
            objSaCatV.URL              = obj.URL;
            objSaCatV.MetaDiscription  = obj.MetaDiscription;
            objSaCatV.Keywords         = obj.Keywords;
            objSaCatV.ProductList      = productList;

            objSaCatV.Product = obj.Product.ToString();


            return(View("add-Deals", objSaCatV));
        }
Ejemplo n.º 8
0
        public bool EditDeals(SA_Deals Deals)
        {
            //  Deals.CreatedDate = DateTime.Now;
            SA_Deals EditDeals = _context.SA_Deals.Where(Cat => Cat.id == Deals.id).FirstOrDefault();

            EditDeals.DealsName        = Deals.DealsName;
            EditDeals.DealsDiscription = Deals.DealsDiscription;
            EditDeals.URL             = Deals.URL;
            EditDeals.MetaDiscription = Deals.MetaDiscription;
            EditDeals.MetaTitle       = Deals.MetaTitle;
            EditDeals.Keywords        = Deals.Keywords;
            EditDeals.Product         = Deals.Product;
            EditDeals.CreatedTime     = Deals.CreatedTime;
            if (Deals.DealsImg != null)
            {
                EditDeals.DealsImg = Deals.DealsImg;
            }
            _context.Entry(EditDeals).State = EntityState.Modified;
            int x = _context.SaveChanges();

            return(x == 0 ? false : true);
        }