Пример #1
0
        public ActionResult Index(ReportMenuViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                int language = LanguageBL.CheckLanguageSession();
                switch (vmodel.TypeReportId)
                {
                case "1":
                    vmodel.ReportTotalSales = ReportBL.FindReportTotalSales(vmodel, language);
                    ViewBag.report          = true;
                    ViewBag.TypeReportId    = vmodel.TypeReportId;
                    return(PartialView("_PartialReportTotalSales", vmodel.ReportTotalSales));

                case "2":
                    vmodel.ReportTotalSalesByProduct = ReportBL.FindReportTotalSalesByProduct(vmodel, language);
                    ViewBag.report       = true;
                    ViewBag.TypeReportId = vmodel.TypeReportId;
                    return(PartialView("_PartialReportTotalSalesByProduct", vmodel.ReportTotalSalesByProduct));

                default:
                    break;
                }
            }
            vmodel.TypesReport = ReportBL.FindAllTypesReport();
            return(View(vmodel));
        }
Пример #2
0
        // GET: Messages
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Index(string sortOrder, string searchString)
        {
            string nameSetting = "MessageGen";
            string messageG    = SettingBL.FindSettingValueByName(nameSetting);

            ViewBag.messageG = int.Parse(messageG);
            int lang      = LanguageBL.CheckLanguageSession();
            var messagesT = db.SPP_MessageTransDistinct(lang).ToList();

            ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!String.IsNullOrEmpty((searchString)))
            {
                messagesT = messagesT.Where(s => s.title.ToLower().StartsWith(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                messagesT = messagesT.OrderByDescending(d => d.title).ToList();
                break;

            default:
                messagesT = messagesT.OrderBy(d => d.title).ToList();
                break;
            }

            return(View(messagesT));
        }
Пример #3
0
        public ActionResult Edit(ProductViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                db.Entry(vmodel.Product).State = EntityState.Modified;
                //db.SaveChanges();
                IList <PRODUCT_TRANSLATION> productsT = TranslationBL.VerifyIsUniversal(vmodel.ProductsTrans, vmodel.IdProduct);
                foreach (var item in vmodel.ProductsTrans)
                {
                    db.Entry(item).State = EntityState.Modified;
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            bool isUniversal = false;

            if (vmodel.ProductsTrans.Count() == 1)
            {
                isUniversal = true;
            }
            ViewBag.isUniversal = isUniversal;
            int lang  = LanguageBL.CheckLanguageSession();
            int ULang = LanguageBL.FindUniversalId();

            vmodel.ListLang        = LanguageBL.FindLanguageListWithoutUniversal();
            vmodel.CategoriesTrans = db.CATEGORY_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList();
            vmodel.Ages            = db.AGEs.ToList();
            vmodel.Brands          = db.BRANDs.ToList();
            vmodel.HeroesTrans     = db.HERO_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList();
            vmodel.Vats            = db.VATs.ToList();

            return(View(vmodel));
        }
Пример #4
0
        // GET: Terminals/Create
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Create()
        {
            int lang      = LanguageBL.CheckLanguageSession();
            int universal = db.LANGUAGESs.Where(l => l.shortForm == "all").Select(s => s.idLanguage).Single();

            ViewBag.shopId = new SelectList(db.SHOP_TRANSLATIONs.Include(t => t.SHOP).Where(s => s.languageId == lang || s.languageId == universal), "shopId", "nameShop");
            return(View());
        }
Пример #5
0
        // GET: Categories
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Index(string sortOrder, string searchString)
        {
            CategoryViewModel vm = new CategoryViewModel();
            //Find all cat by language
            int lang        = LanguageBL.CheckLanguageSession();
            var categoriesT = db.SPP_CategoryTransDistinct(lang).ToList();
            //Find relation for all cat
            IList <int> parentOnly         = db.SPP_ParentCategoriesSubTransDistinct(lang).Select(p => p.idCategory).ToList();
            IList <int> childOnly          = db.SPP_ChildCategoriesTransDistinct(lang).Select(p => p.idCategory).ToList();
            IList <CategoryViewModel> list = new List <CategoryViewModel>();
            string rel;

            foreach (var item in categoriesT)
            {
                if (childOnly.Contains(item.idCategory) && parentOnly.Contains(item.idCategory))
                {
                    rel = "parent/sous-catégorie";
                }
                else if (childOnly.Contains(item.idCategory))
                {
                    rel = "sous-catégorie";
                }
                else
                {
                    rel = "catégorie parent";
                }

                CategoryViewModel cat = new CategoryViewModel
                {
                    IdCat    = item.idCategory,
                    NameCat  = item.nameCategory,
                    Image    = item.imageCat,
                    Relation = rel
                };
                list.Add(cat);
            }

            ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!String.IsNullOrEmpty((searchString)))
            {
                list = list.Where(s => s.NameCat.ToLower().StartsWith(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                list = list.OrderByDescending(d => d.NameCat).ToList();
                break;

            default:
                list = list.OrderBy(d => d.NameCat).ToList();
                break;
            }

            return(View(list));
        }
Пример #6
0
        // GET: Categories/Create
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Create()
        {
            int lang             = LanguageBL.CheckLanguageSession();
            CategoryViewModel vm = new CategoryViewModel
            {
                ListLang   = LanguageBL.FindLanguageListWithoutUniversal(),
                Categories = db.SPP_CategoryTransDistinct(lang).ToList()
            };

            return(View(vm));
        }
Пример #7
0
        // GET: Messages/Delete/5
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int lang = LanguageBL.CheckLanguageSession();

            SPP_MessageTransDistinct_Result messages = db.SPP_MessageTransDistinct(lang).Where(m => m.idMessage == id).Single();

            return(View(messages));
        }
Пример #8
0
        public ActionResult Create(CategoryViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                //Check if nameHero have min  1 value
                IList <CATEGORY_TRANSLATION> catsT = vmodel.CategoriesTrans;
                bool nameCatIsValid = TranslationBL.CheckIfMinOneValued(catsT);
                if (nameCatIsValid)
                {
                    //Check if Cat exist by nameCategory before create
                    bool nameExist = TranslationBL.CheckIfNameExist(catsT);
                    if (!nameExist)
                    {
                        CATEGORY cat = new CATEGORY
                        {
                            imageCat = vmodel.Image
                        };
                        db.CATEGORYs.Add(cat);
                        db.SaveChanges();
                        //Add Translation
                        int id = cat.idCategory;
                        IList <CATEGORY_TRANSLATION> newcatsT = TranslationBL.VerifyIsUniversal(catsT, id);
                        db.CATEGORY_TRANSLATIONs.AddRange(newcatsT);
                        db.SaveChanges();

                        if (vmodel.Parent != null)
                        {
                            SUBCATEGORY subCat = new SUBCATEGORY {
                                parentCategory = vmodel.Parent.Value,
                                childCategory  = cat.idCategory
                            };
                            db.SUBCATEGORYs.Add(subCat);
                            db.SaveChanges();
                        }
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        //to do --> match the error with the name that causes the error
                        ViewBag.nameIsNotValid = "Le nom existe déjà, veuillez saisir un autre nom!";
                    }
                }
                else
                {
                    ViewBag.nameIsNotValid = "Veuillez saisir un nom!";
                }
            }
            int lang = LanguageBL.CheckLanguageSession();

            vmodel.ListLang   = LanguageBL.FindLanguageListWithoutUniversal();
            vmodel.Categories = db.SPP_CategoryTransDistinct(lang).ToList();
            return(View(vmodel));
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "idTerminal,nameTerminal,shopId")] TERMINAL terminal)
        {
            if (ModelState.IsValid)
            {
                db.TERMINALs.Add(terminal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            int lang      = LanguageBL.CheckLanguageSession();
            int universal = db.LANGUAGESs.Where(l => l.shortForm == "all").Select(s => s.idLanguage).Single();

            ViewBag.shopId = new SelectList(db.SHOP_TRANSLATIONs.Include(t => t.SHOP).Where(s => s.languageId == lang || s.languageId == universal), "shopId", "nameShop");
            return(View(terminal));
        }
Пример #10
0
        // GET: Products/Edit/5
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PRODUCT pRODUCT = db.PRODUCTs.Find(id);

            if (pRODUCT == null)
            {
                return(HttpNotFound());
            }
            var translation = db.PRODUCT_TRANSLATIONs.Where(pt => pt.productId == id).ToList();

            ProductViewModel vm          = new ProductViewModel();
            bool             isUniversal = false;

            if (translation.Count() == 1)
            {
                isUniversal = true;
            }
            ViewBag.isUniversal = isUniversal;

            vm.Product = pRODUCT;

            vm.IdProduct    = pRODUCT.idProduct;
            vm.Barcode      = pRODUCT.barcode;
            vm.Price        = pRODUCT.salesPrice;
            vm.Discount     = pRODUCT.discountRate;
            vm.ImageProduct = pRODUCT.imageProduct;
            vm.Category     = pRODUCT.categoryId.ToString();
            vm.Age          = pRODUCT.ageId.ToString();
            vm.Brand        = pRODUCT.brandId.ToString();
            vm.Hero         = pRODUCT.heroId.ToString();

            vm.ProductsTrans = translation;

            int lang  = LanguageBL.CheckLanguageSession();
            int ULang = LanguageBL.FindUniversalId();

            vm.ListLang        = LanguageBL.FindLanguageListWithoutUniversal();
            vm.CategoriesTrans = db.CATEGORY_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList();
            vm.Ages            = db.AGEs.ToList();
            vm.Brands          = db.BRANDs.ToList();
            vm.HeroesTrans     = db.HERO_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList();
            vm.Vats            = db.VATs.ToList();
            return(View(vm));
        }
Пример #11
0
        // GET: Products/Create
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Create()
        {
            int lang            = LanguageBL.CheckLanguageSession();
            int ULang           = LanguageBL.FindUniversalId();
            ProductViewModel vm = new ProductViewModel
            {
                ListLang        = LanguageBL.FindLanguageListWithoutUniversal(),
                CategoriesTrans = db.CATEGORY_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList(),
                Ages            = db.AGEs.ToList(),
                Brands          = db.BRANDs.ToList(),
                HeroesTrans     = db.HERO_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList(),
                Vats            = db.VATs.ToList()
            };

            return(View(vm));
        }
Пример #12
0
        // GET: Terminals/Edit/5
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TERMINAL terminal = db.TERMINALs.Find(id);

            if (terminal == null)
            {
                return(HttpNotFound());
            }
            int lang      = LanguageBL.CheckLanguageSession();
            int universal = db.LANGUAGESs.Where(l => l.shortForm == "all").Select(s => s.idLanguage).Single();

            ViewBag.shopId = new SelectList(db.SHOP_TRANSLATIONs.Include(t => t.SHOP).Where(s => s.languageId == lang || s.languageId == universal), "shopId", "nameShop", terminal.shopId);
            return(View(terminal));
        }
Пример #13
0
        // GET: Shops
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Index(string sortOrder, string searchString)
        {
            int lang   = LanguageBL.CheckLanguageSession();
            var shopsT = db.SPP_ShopTransDistinct(lang).ToList();

            ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!String.IsNullOrEmpty((searchString)))
            {
                shopsT = shopsT.Where(s => s.nameShop.ToLower().StartsWith(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                shopsT = shopsT.OrderByDescending(d => d.nameShop).ToList();
                break;

            default:
                shopsT = shopsT.OrderBy(d => d.nameShop).ToList();
                break;
            }

            return(View(shopsT));
        }
Пример #14
0
        public ActionResult Create(ProductViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //if no image, assign default image
                    string img = vmodel.ImageProduct;
                    if (img == null)
                    {
                        img = "~/Content/image/logo_noImage.png";
                    }
                    // check if hero is null
                    int?hero = null;
                    if (vmodel.Hero != null)
                    {
                        hero = int.Parse(vmodel.Hero);
                    }
                    PRODUCT product = new PRODUCT
                    {
                        barcode      = vmodel.Barcode,
                        salesPrice   = vmodel.Price,
                        discountRate = vmodel.Discount,
                        imageProduct = img,
                        categoryId   = int.Parse(vmodel.Category),
                        ageId        = int.Parse(vmodel.Age),
                        brandId      = int.Parse(vmodel.Brand),
                        heroId       = hero,
                        vatId        = int.Parse(vmodel.Vat)
                    };
                    db.PRODUCTs.Add(product);
                    db.SaveChanges();

                    //Add Translation
                    int id = product.idProduct;
                    IList <PRODUCT_TRANSLATION> productsT = TranslationBL.VerifyIsUniversal(vmodel.ProductsTrans, id);

                    db.PRODUCT_TRANSLATIONs.AddRange(productsT);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    //to do insert to log file
                    var e1 = ex.GetBaseException(); // --> log
                    var e4 = ex.Message;            // --> log
                    var e5 = ex.Source;             // --> log
                    var e8 = ex.GetType();          // --> log
                    var e9 = ex.GetType().Name;     // --> log
                    return(View("Error"));
                }
            }
            int lang  = LanguageBL.CheckLanguageSession();
            int ULang = LanguageBL.FindUniversalId();

            vmodel.ListLang        = LanguageBL.FindLanguageListWithoutUniversal();
            vmodel.CategoriesTrans = db.CATEGORY_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList();
            vmodel.Ages            = db.AGEs.ToList();
            vmodel.Brands          = db.BRANDs.ToList();
            vmodel.HeroesTrans     = db.HERO_TRANSLATIONs.Where(c => c.languageId == lang || c.languageId == ULang).ToList();
            vmodel.Vats            = db.VATs.ToList();
            return(View(vmodel));
        }