コード例 #1
0
 public ActionResult DeleteCategory(int NidCategory)
 {
     dbTransfer = new DbTransfer();
     //check for brands and type and product
     if (dbTransfer.CheckForBrandByNidcategory(NidCategory) || dbTransfer.CheckForTypeByNidcategory(NidCategory) || dbTransfer.CheckForProductByNidcategory(NidCategory))
     {
         return(Json(new JsonResults()
         {
             HasValue = false, Message = "حذف امکان پذیر نمی باشد.دسته بندی دارای محصول یا برند یا نوع می باشد"
         }));
     }
     else
     {
         dbTransfer.Delete(dbTransfer.GetCategoryByNidCategory(NidCategory));
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true, Message = "دسته بندی با موفقیت حذف گردید"
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در حذف"
             }));
         }
     }
 }
コード例 #2
0
 public ActionResult DeleteBrand(Guid NidBrand)
 {
     dbTransfer = new DbTransfer();
     //check for product
     if (dbTransfer.CheckForProductByNidBrand(NidBrand))
     {
         return(Json(new JsonResults()
         {
             HasValue = false, Message = "این برند دارای محصول می باشد"
         }));
     }
     else
     {
         dbTransfer.Delete(dbTransfer.GetCategoryBrandByNidBrand(NidBrand));
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true, Message = "برند با موفقیت حذف گردید"
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در حذف"
             }));
         }
     }
 }
コード例 #3
0
        public ActionResult GetEditCategory(int NidCategory)
        {
            dbTransfer = new DbTransfer();
            Category category = dbTransfer.GetCategoryByNidCategory(NidCategory);
            List <Tuple <string, string, bool> > typelabels  = new List <Tuple <string, string, bool> >();
            List <Tuple <string, string, bool> > brandlabels = new List <Tuple <string, string, bool> >();

            foreach (var lbl in category.Category_Types)
            {
                typelabels.Add(new Tuple <string, string, bool>(lbl.NidType.ToString(), lbl.TypeName, false));
            }
            foreach (var lbl in category.Category_Brands)
            {
                brandlabels.Add(new Tuple <string, string, bool>(lbl.NidBrand.ToString(), lbl.BrandName, true));
            }
            string types  = RenderViewToString(this.ControllerContext, "_CategoryBrandAndTypeLabel", typelabels);
            string brands = RenderViewToString(this.ControllerContext, "_CategoryBrandAndTypeLabel", brandlabels);
            string pics   = "";

            if (category.Pictures != null)
            {
                pics = RenderViewToString(this.ControllerContext, "_UploadedImages", category.Pictures.Split(',').ToList());
            }
            TempData["NidEditcategory"] = category.NidCategory;
            return(Json(new JsonCategoryEdit()
            {
                CategoryName = category.CategoryName, Description = category.Description, Keywords = category.keywords, NidCategory = category.NidCategory, BrandWrap = brands, TypeWrap = types, PicturesWrap = pics, Pictures = category.Pictures
            }));
        }
コード例 #4
0
        //users
        public ActionResult Users()
        {
            dbTransfer = new DbTransfer();
            var userList = dbTransfer.GetAllUsers(100);

            return(View("Users", userList));
        }
コード例 #5
0
 public ActionResult DeleteProduct(Guid NidProduct)
 {
     dbTransfer = new DbTransfer();
     //check for orders
     if (dbTransfer.CheckForOrderByNidProduct(NidProduct))
     {
         return(Json(new JsonResults()
         {
             HasValue = false, Message = "این محصول دارای سفارش می باشد"
         }));
     }
     else
     {
         dbTransfer.Delete(dbTransfer.GetProductByProductId(NidProduct));
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true, Message = "محصول با موفقیت حذف گردید"
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در حذف"
             }));
         }
     }
 }
コード例 #6
0
        //category section
        public ActionResult Categories()
        {
            dbTransfer = new DbTransfer();
            var categoryList = dbTransfer.GetAllCategories(100);

            return(View("Categories", categoryList));
        }
コード例 #7
0
        // GET: Home
        public ActionResult Index()
        {
            dbTransfer = new DbTransfer();
            List <Setting> sets = dbTransfer.GetAllSettings();

            return(View(sets));
        }
コード例 #8
0
        public ActionResult SyncBnTTable(bool IsBrand, int NidCategory)
        {
            CategoryAndBrandViewModel cbvm = new CategoryAndBrandViewModel();

            if (NidCategory != -1)
            {
                dbTransfer = new DbTransfer();
                if (IsBrand)
                {
                    cbvm.category_Brand = dbTransfer.GetCategoryByNidCategory(NidCategory).Category_Brands.ToList();
                    cbvm.IsBrand        = true;
                }
                else
                {
                    cbvm.category_Type = dbTransfer.GetCategoryByNidCategory(NidCategory).Category_Types.ToList();
                    cbvm.IsBrand       = false;
                }
            }
            else
            {
                cbvm.IsBrand = true;
            }
            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_BnTTable", cbvm)
            }));
        }
コード例 #9
0
        //products
        public ActionResult Products()
        {
            dbTransfer = new DbTransfer();
            var prods = dbTransfer.GetAllProducts(100);

            return(View(prods));
        }
コード例 #10
0
        //orders
        public ActionResult Orders()
        {
            dbTransfer = new DbTransfer();
            var orders = dbTransfer.GetAllOrders(1000);

            return(View(orders));
        }
コード例 #11
0
 public ActionResult AddUser(string Username, string Password, string Name = "", string LastName = "")
 {
     dbTransfer = new DbTransfer();
     if (!dbTransfer.CheckForUserExistance(Username.Trim()))
     {
         dbTransfer.Add(new User()
         {
             NidUser = Guid.NewGuid(), CreateDate = DateTime.Now, Enabled = true, FirstName = Name, LastName = LastName, IsAdmin = true, Password = DbTransfer.Encrypt(Password), Username = Username
         });
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true, Message = "کاربر با موفقیت ایجاد شد"
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در دیتابیس"
             }));
         }
     }
     else
     {
         return(Json(new JsonResults()
         {
             HasValue = false, Message = "این نام کاربری موجود می باشد"
         }));
     }
 }
コード例 #12
0
        public ActionResult ManageTypeAndBrand(bool IsBrand)
        {
            int NidCategory = int.Parse(TempData["NidEditcategory"].ToString());

            dbTransfer = new DbTransfer();
            CategoryAndBrandViewModel cbvm = new CategoryAndBrandViewModel();

            if (NidCategory != -1)
            {
                Category category = dbTransfer.GetCategoryByNidCategory(NidCategory);
                if (IsBrand)
                {
                    cbvm.category_Brand = category.Category_Brands.ToList();
                    cbvm.IsBrand        = true;
                }
                else
                {
                    cbvm.category_Type = category.Category_Types.ToList();
                    cbvm.IsBrand       = false;
                }
                cbvm.NidCategory  = category.NidCategory;
                cbvm.CategoryName = category.CategoryName;
            }

            return(View(cbvm));
        }
コード例 #13
0
        public ActionResult AcceptedComments()
        {
            dbTransfer = new DbTransfer();
            var comments = dbTransfer.GetAllComments(100, true);

            TempData["Comments"] = "1";
            return(View("Comments", comments));
        }
コード例 #14
0
        //comments
        public ActionResult Comments()
        {
            dbTransfer = new DbTransfer();
            var comments = dbTransfer.GetAllComments(100);

            TempData["Comments"] = "0";
            return(View(comments));
        }
コード例 #15
0
        public ActionResult AddProduct()
        {
            ProductViewModel pvm = new ProductViewModel();

            dbTransfer     = new DbTransfer();
            pvm.Categories = dbTransfer.GetAllCategories(100);
            return(View(pvm));
        }
コード例 #16
0
        //ships
        public ActionResult Ships()
        {
            dbTransfer = new DbTransfer();
            ShipsViewModel svm = new ShipsViewModel();

            svm.Doing = dbTransfer.GetAllDoingShips(100);
            svm.Done  = dbTransfer.GetAllDoneShips(100);
            return(View(svm));
        }
コード例 #17
0
        public ActionResult CategoryDetail(int NidCategory)
        {
            dbTransfer = new DbTransfer();
            Category category = dbTransfer.GetCategoryByNidCategory(NidCategory);

            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_CategoryDetail", category)
            }));
        }
コード例 #18
0
        public ActionResult EditBrand(Guid NidBrand)
        {
            dbTransfer = new DbTransfer();
            Category_Brands brand = dbTransfer.GetCategoryBrandByNidBrand(NidBrand);

            return(Json(new JsonBnTEdit()
            {
                Description = brand.Description, Keywords = brand.Keywords, Name = brand.BrandName, Nid = brand.NidBrand.ToString()
            }));
        }
コード例 #19
0
        public ActionResult ShipDetail(Guid NidShip)
        {
            dbTransfer = new DbTransfer();
            Ship ship = dbTransfer.GetShipByNidShip(NidShip);

            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_ShipDetail", ship)
            }));
        }
コード例 #20
0
        public ActionResult OrderDetail(Guid NidOrder)
        {
            dbTransfer = new DbTransfer();
            Order order = dbTransfer.GetOrderByNidOrder(NidOrder);

            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_OrderDetail", order)
            }));
        }
コード例 #21
0
        public ActionResult EditType(Guid NidType)
        {
            dbTransfer = new DbTransfer();
            Category_Types type = dbTransfer.GetCategoryTypeByNidType(NidType);

            return(Json(new JsonBnTEdit()
            {
                Description = type.Description, Keywords = type.Keywords, Name = type.TypeName, Nid = type.NidType.ToString()
            }));
        }
コード例 #22
0
        public ActionResult SyncUserTable()
        {
            dbTransfer = new DbTransfer();
            var userlist = dbTransfer.GetAllUsers(100);

            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_UserTable", userlist)
            }));
        }
コード例 #23
0
        public ActionResult SyncCategoryTable()
        {
            dbTransfer = new DbTransfer();
            var categoryList = dbTransfer.GetAllCategories(100);

            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_CategoryTable", categoryList)
            }));
        }
コード例 #24
0
        public ActionResult EditProduct(Guid NidProduct)
        {
            ProductViewModel pvm = new ProductViewModel();

            dbTransfer = new DbTransfer();
            Product product = dbTransfer.GetProductByProductId(NidProduct);

            pvm.Categories      = dbTransfer.GetAllCategories();
            pvm.Category_Brands = dbTransfer.GetCategoryBrandsByNidCategory(product.NidCategory);
            pvm.category_Types  = dbTransfer.GetCategoryTypesByNidCategory(product.NidCategory);
            pvm.Product         = product;
            //pvm.ProductDescription = product.Description.Replace("\"", "\\\"");
            return(View(pvm));
        }
コード例 #25
0
        //settings
        public ActionResult UpdateSetting(int SettingIndex, string SettingValue)
        {
            dbTransfer = new DbTransfer();
            Setting setting = null;

            //1:specialBanner,2:popularBanner
            switch (SettingIndex)
            {
            case 1:
                setting = new Setting()
                {
                    NidSetting = Guid.NewGuid(), SettingAttribute = "specialBanner", SettingValue = SettingValue
                };
                break;

            case 2:
                setting = new Setting()
                {
                    NidSetting = Guid.NewGuid(), SettingAttribute = "popularBanner", SettingValue = SettingValue
                };
                break;
            }
            if (setting != null)
            {
                dbTransfer.Add(setting);
                if (dbTransfer.Save())
                {
                    return(Json(new JsonResults()
                    {
                        HasValue = true, Message = "تنظیمات با موفقیت ثبت شد"
                    }));
                }
                else
                {
                    return(Json(new JsonResults()
                    {
                        HasValue = false, Message = "خطا در دیتابیس"
                    }));
                }
            }
            else
            {
                return(Json(new JsonResults()
                {
                    HasValue = false, Message = "تنظیمات ناشناخته"
                }));
            }
        }
コード例 #26
0
        public static TransferRule MakeTransferRule()
        {
            TransferRule aMockRule = new TransferRule();

            aMockRule.RuleName = "新建数据迁移策略";
            DbTransfer dt = new DbTransfer();

            dt.DbName = _RestoreDbName;
            TableTransfer tt = new TableTransfer();

            tt.TableName = _MainTableName;
            dt.AddTransferTable(tt);
            aMockRule.DbsToTransfer.Add(dt);

            return(aMockRule);
        }
コード例 #27
0
 public ActionResult SubmitEditProduct(ProductViewModel pvm)
 {
     dbTransfer = new DbTransfer();
     pvm.Product.LastModified = DateTime.Now;
     dbTransfer.Update(pvm.Product);
     if (dbTransfer.Save())
     {
         TempData["SucessfullAddProduct"] = "محصول با موفقیت ویرایش گردید";
         return(RedirectToAction("Products"));
     }
     else
     {
         TempData["ErrorEditProduct"] = "خطا در دیتابیس";
         return(RedirectToAction("EditProduct", new { NidProduct = pvm.Product.NidProduct }));
     }
 }
コード例 #28
0
 public ActionResult ManageType(bool IsNewType, string Name, int NidCategory, string Description = "", string Keywords = "", string NidType = "")
 {
     dbTransfer = new DbTransfer();
     if (IsNewType)
     {
         Category_Types cb = new Category_Types()
         {
             TypeName = Name, NidType = Guid.NewGuid(), Description = Description, Keywords = Keywords, NidCategory = NidCategory
         };
         dbTransfer.Add(cb);
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در دیتابیس"
             }));
         }
     }
     else
     {
         Category_Types cb = dbTransfer.GetCategoryTypeByNidType(Guid.Parse(NidType));
         cb.TypeName = Name; cb.Description = Description; cb.Keywords = Keywords;
         dbTransfer.Update(cb);
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در دیتابیس"
             }));
         }
     }
 }
コード例 #29
0
 public ActionResult SubmitAddProduct(ProductViewModel pvm)
 {
     pvm.Product.CreateDate = DateTime.Now;
     pvm.Product.NidProduct = Guid.NewGuid();
     dbTransfer             = new DbTransfer();
     dbTransfer.Add(pvm.Product);
     if (dbTransfer.Save())
     {
         TempData["SucessfullAddProduct"] = "محصول با موفقیت اضافه شد";
         return(RedirectToAction("Products"));
     }
     else
     {
         TempData["ErrorAddProduct"] = "خطا در دیتابیس";
         return(RedirectToAction("AddProduct"));
     }
 }
コード例 #30
0
        public ActionResult SyncShipsTable(bool IsShipDone)
        {
            dbTransfer = new DbTransfer();
            ShipsViewModel svm = new ShipsViewModel();

            if (IsShipDone)
            {
                svm.Done = dbTransfer.GetAllDoneShips(100);
            }
            else
            {
                svm.Doing = dbTransfer.GetAllDoingShips(100);
            }
            svm.IsDone = IsShipDone;
            return(Json(new JsonResults()
            {
                HasValue = true, Html = RenderViewToString(this.ControllerContext, "_ShipTable", svm)
            }));
        }