Exemplo n.º 1
0
        public ActionResult Create(Product product, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                product.ProductId = Guid.NewGuid();
                var image = new FileBO().Insert(file);
                product.FileId = image.FileId;
                product.File   = image;
                db.Product.Add(product);
                if (db.SaveChanges() > 0)
                {
                    if (Session["Color"] != null)
                    {
                        var colorList = (List <Color>)Session["Color"];
                        foreach (var item in colorList)
                        {
                            item.ProductId = product.ProductId;
                            db.Color.Add(item);
                            db.SaveChanges();
                        }
                    }
                    return(RedirectToAction("Index"));
                }
            }


            return(View(product));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "CategoryId,CategoryName,LangId")] Category category, HttpPostedFileBase image)
        {
            category.CategoryId = Guid.NewGuid();
            var file = new File();

            file.FileId = Guid.NewGuid();
            if (image != null)
            {
                file.Context = new byte[image.ContentLength];
                image.InputStream.Read(file.Context, 0, image.ContentLength);
                file.ContextType = image.ContentType;
                file.Title       = image.FileName;
            }

            db.File.Add(file);


            category.FileId = file.FileId;
            db.Category.Add(category);
            if (db.SaveChanges() > 0)
            {
                return(RedirectToAction("Index"));
            }



            return(View(category));
        }
Exemplo n.º 3
0
        public ActionResult Create(OfferCard offerCard)
        {
            if (ModelState.IsValid)
            {
                db.OfferCards.Add(offerCard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(offerCard));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,Value,ProductId,Enable,Name")] Color color)
        {
            if (ModelState.IsValid)
            {
                color.Id = Guid.NewGuid();
                db.Color.Add(color);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(color));
        }
Exemplo n.º 5
0
        public ActionResult Create(Advertise advertise, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                db.Advertises.Add(advertise);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FileId = new SelectList(db.File, "FileId", "ContextType", advertise.FileId);
            return(View(advertise));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "ContactId,FullName,Email,Phone,Message")] Cantact cantact)
        {
            if (ModelState.IsValid)
            {
                cantact.ContactId = Guid.NewGuid();
                db.Cantact.Add(cantact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cantact));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "CustomerId,FirstName,LastName,UserName,PassWord,Email,Phone,Address")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                customer.CustomerId = Guid.NewGuid();
                db.Customer.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "ExtraImagesId,FileId,ProductId")] ExtraImages extraImages)
        {
            if (ModelState.IsValid)
            {
                extraImages.ExtraImagesId = Guid.NewGuid();
                db.ExtraImages.Add(extraImages);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId = new SelectList(db.Product, "ProductId", "ProductName", extraImages.ProductId);
            return(View(extraImages));
        }
Exemplo n.º 9
0
        public ActionResult Create(OfferBanner offerBanner, HttpPostedFileBase file)
        {
            File image = new FileBO().Insert(file);

            offerBanner.FileId = image.FileId;
            //offerBanner.File = image;
            db.OfferBanners.Add(offerBanner);
            if (db.SaveChanges() > 0)
            {
                return(RedirectToAction("Index"));
            }



            return(View(offerBanner));
        }
Exemplo n.º 10
0
        public string AddComment(Guid id, string name, string title, string message)
        {
            if (id == Guid.Empty)
            {
                return("خطا در ارسال نظر");
            }
            if (string.IsNullOrEmpty(name))
            {
                return("لطفا نام خود را وارد کنید");
            }
            if (string.IsNullOrEmpty(title))
            {
                return("لطفا عنوان را وارد کنید");
            }
            if (string.IsNullOrEmpty(message))
            {
                return("نظر خود را بنویسید");
            }
            var obj = new UserComments()
            {
                ProductId = id,
                FullName  = name,
                Title     = title,
                Message   = message,
                IsAccept  = false
            };

            db.UserComments.Add(obj);
            db.SaveChanges();
            return("نطر شما با موفقیت ثبت شد");
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "Title,Content,LangId")] News news, HttpPostedFileBase imageid, HttpPostedFileBase videoid)
        {
            var image = new FileBO().NewsInsert(imageid);
            var video = new FileBO().NewsInsert(videoid);

            news.ImageId  = image.FileId;
            news.VideoId  = video.FileId;
            news.SaveDate = Utility.CurrentDate(DateTime.Now, news.LangId);
            db.News.Add(news);
            if (db.SaveChanges() > 0)
            {
                return(RedirectToAction("Index"));
            }


            return(View(news));
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "WallPaperId,Title,Position,Description")] WallPaper WallPaper, HttpPostedFileBase file)
        {
            WallPaper.WallPaperId = Guid.NewGuid();
            var image = new FileBO().Insert(file);

            WallPaper.FileId = image.FileId;
            WallPaper.File   = image;
            db.WallPaper.Add(WallPaper);
            if (db.SaveChanges() > 0)
            {
                return(RedirectToAction("Index"));
            }



            return(View(WallPaper));
        }
Exemplo n.º 13
0
        public bool Delete(Guid id)
        {
            var db   = new ClockStoreContext();
            var file = new ClockStoreContext().File.Find(id);

            db.Entry(file).State = EntityState.Deleted;
            db.File.Remove(file);
            return(db.SaveChanges() > 0);
        }
Exemplo n.º 14
0
        public static void ClearBasket(Guid customerId)
        {
            var db   = new ClockStoreContext();
            var list = db.Basket.ToList().Where(c => c.CustomerId == customerId && c.IsArchive == false);

            if (list != null)
            {
                foreach (var item in list)
                {
                    if (item.Product.IsBlocked.HasValue && item.Product.IsBlocked.Value)
                    {
                        item.Product.IsBlocked       = false;
                        db.Entry(item.Product).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    db.Basket.Remove(item);
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "BasketId,ProductId,CustomerId,Quantity,SaveDate,Status")] Basket basket)
        {
            if (ModelState.IsValid)
            {
                basket.BasketId = Guid.NewGuid();
                db.Basket.Add(basket);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(db.Customer, "CustomerId", "FirstName", basket.CustomerId);
            ViewBag.ProductId  = new SelectList(db.Product, "ProductId", "ProductName", basket.ProductId);
            return(View(basket));
        }
Exemplo n.º 16
0
        public File Insert(HttpPostedFileBase image)
        {
            var file = new File();

            file.FileId = Guid.NewGuid();
            if (image != null)
            {
                file.Context = new byte[image.ContentLength];
                image.InputStream.Read(file.Context, 0, image.ContentLength);
                file.ContextType = image.ContentType;
                file.Title       = image.FileName;
            }
            var d = new ClockStoreContext();

            d.File.Add(file);

            d.SaveChanges();
            return(file);
        }
Exemplo n.º 17
0
        // GET: Payment
        public ActionResult Index(Guid id, string offerCode)
        {
            if (SessionParameters.Customer == null)
            {
                return(Redirect("/Customers/Signin"));
            }

            List <Basket> baskets = db.Basket.Where(c => c.CustomerId == SessionParameters.Customer.CustomerId && c.IsArchive == false).ToList();

            Order order = new Order
            {
                OrderId      = Guid.NewGuid(),
                SaveDate     = DateTime.Now,
                IsFinaly     = false,
                CurrentPrice = baskets.Sum(c => c.Product.PriceWithOff)
            };

            if (!string.IsNullOrEmpty(offerCode))
            {
                OfferCard offer   = db.OfferCards.FirstOrDefault(c => c.OfferCode == offerCode);
                bool      isvalid = db.CustomerOffers.Any(c => c.CustomerId == SessionParameters.Customer.CustomerId && c.OfferCardId == offer.Id);
                if (!isvalid)
                {
                    order.OfferCardId = offer.Id;
                    switch (offer.OfferType)
                    {
                    case Enums.OfferType.TwoByOne:
                        break;

                    case Enums.OfferType.percent:
                        order.CurrentPrice = order.CurrentPrice - (order.CurrentPrice * offer.OfferAmount / 100);
                        break;

                    case Enums.OfferType.Price:
                        order.CurrentPrice = order.CurrentPrice - Convert.ToDecimal(offer.OfferCode);
                        break;
                    }
                }
            }
            //order.CurrentPrice = 100;
            db.Order.Add(order);
            db.SaveChanges();

            System.Net.ServicePointManager.Expect100Continue = false;
            ZarinPal.PaymentGatewayImplementationServicePortTypeClient zp = new ZarinPal.PaymentGatewayImplementationServicePortTypeClient();
            int    Amount = Convert.ToInt32(order.CurrentPrice);
            string url    = "http://kookwatch.com/Payment/Verify?cusId=" + SessionParameters.Customer.CustomerId + "&orderid=" + order.OrderId + "";
            //var url = "http://*****:*****@kookwatch.com", "09120332214", url, out string Authority);

            if (Status == 100)
            {
                Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority);
                //Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + Authority);
            }
            else
            {
                ViewBag.Error = "Error : " + Status;
            }
            return(View());
        }
Exemplo n.º 18
0
 public virtual bool Insert(TDBModel obj)
 {
     this.CheckConstraint(obj);
     db.Set <TDBModel>().Add(obj);
     return(db.SaveChanges() > 0);
 }