Beispiel #1
0
 public ActionResult Create(MessageViewModel vmodel)
 {
     if (ModelState.IsValid)
     {
         //Check if  min  1 value
         bool messageIsValid = TranslationBL.CheckIfMinOneValue(vmodel.MessagesTrans);
         if (messageIsValid)
         {
             //Check if Message exist by title before create
             bool titleExist = TranslationBL.CheckIfNameExist(vmodel.MessagesTrans);
             if (!titleExist)
             {
                 MESSAGE message = new MESSAGE();
                 db.MESSAGEs.Add(message);
                 int id = message.idMessage;
                 //Check if isUniversal
                 IList <MESSAGE_TRANSLATION> messagesT = TranslationBL.VerifyIsUniversal(vmodel.MessagesTrans, id);
                 db.MESSAGE_TRANSLATIONs.AddRange(messagesT);
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 //to do --> match the error with the name that causes the error
                 ViewBag.nameIsNotValid = "Le Titre existe déjà, veuillez saisir un autre nom!";
             }
         }
         else
         {
             ViewBag.nameIsNotValid = "Veuillez saisir un titre et un message!";
         }
     }
     vmodel.ListLang = LanguageBL.FindLanguageListWithoutUniversal();
     return(View(vmodel));
 }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "dateDay,beginningCash")] CASH_BOTTOM_DAY cashDay)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    cashDay.terminalId = Convert.ToInt32(Session["sessTerminalId"]);
                    db.CASH_BOTTOM_DAYs.Add(cashDay);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Transaction"));
                }
                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

                    ViewBag.Error      = "Il existe déjà un fond de caisse sur ce terminal pour cette date";
                    ViewBag.terminalId = new SelectList(db.TERMINALs, "idTerminal", "nameTerminal", cashDay.terminalId);
                    return(View(cashDay));
                }
            }
            ViewBag.terminalId = new SelectList(db.TERMINALs, "idTerminal", "nameTerminal", cashDay.terminalId);
            return(View(cashDay));
        }
Beispiel #3
0
        public void CreateUserInfo(string idUser, string name, string firstname, string street, string zipcode, string city, string phone)
        {
            USERINFO info = new USERINFO {
                userId = idUser, nameUser = name, firstname = firstname, street = street, zipCode = zipcode, city = city, phone = phone, creationDate = DateTime.Now
            };

            db.USERINFOs.Add(info);
            db.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "idPaymentMethod,method")] PAYMENT_METHOD pAYMENT_METHOD)
        {
            if (ModelState.IsValid)
            {
                db.PAYMENT_METHOD.Add(pAYMENT_METHOD);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pAYMENT_METHOD));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "idVat,appliedVat")] VAT vAT)
        {
            if (ModelState.IsValid)
            {
                db.VATs.Add(vAT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vAT));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "idLanguage,nameLanguage,shortForm")] LANGUAGES lANGUAGES)
        {
            if (ModelState.IsValid)
            {
                db.LANGUAGESs.Add(lANGUAGES);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(lANGUAGES));
        }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "idRole,nameRole")] AspNetRoles role)
        {
            if (ModelState.IsValid)
            {
                db.AspNetRoles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "idSetting,nameSetting,valueSetting")] SETTING sETTING)
        {
            if (ModelState.IsValid)
            {
                db.SETTINGs.Add(sETTING);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sETTING));
        }
Beispiel #9
0
        public ActionResult Create([Bind(Include = "idBrand,nameBrand,imageBrand")] BRAND bRAND)
        {
            if (ModelState.IsValid)
            {
                db.BRANDs.Add(bRAND);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bRAND));
        }
Beispiel #10
0
        public ActionResult Create(ShopViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //if no image, assign default image
                    string logo = vmodel.LogoShop;
                    if (logo == null)
                    {
                        logo = "~/Content/image/logo_noImage.png";
                    }
                    SHOP shop = new SHOP
                    {
                        logoShop = logo,
                        phone    = vmodel.Phone,
                        email    = vmodel.Email,
                        zipCode  = vmodel.ZipCode
                    };
                    db.SHOPs.Add(shop);
                    db.SaveChanges();

                    //Add Translation
                    int id = shop.idShop;
                    IList <SHOP_TRANSLATION> shopsT = TranslationBL.VerifyIsUniversal(vmodel.ShopsTrans, id);

                    db.SHOP_TRANSLATIONs.AddRange(shopsT);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (DbEntityValidationException 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"));
                }
                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"));
                }
            }
            vmodel.ListLang = LanguageBL.FindLanguageListWithoutUniversal();
            return(View(vmodel));
        }
Beispiel #11
0
        public ActionResult Create([Bind(Include = "idRole,nameRole")] ROLE rOLE)
        {
            if (ModelState.IsValid)
            {
                db.ROLEs.Add(rOLE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rOLE));
        }
Beispiel #12
0
        public int CreateTransaction(int terminal, string vendorId, int shop, int customer)
        {
            STATUS       status = db.STATUSs.Where(s => s.nameStatus.ToLower() == "open").Single();
            TRANSACTIONS tr     = new TRANSACTIONS {
                transactionDateBegin = DateTime.Now, transactionDateEnd = DateTime.Parse("2000-01-01 00:00:00"), terminalId = terminal, userId = vendorId, shopId = shop, statusId = status.idStatus, customerId = customer
            };

            db.TRANSACTIONSs.Add(tr);
            db.SaveChanges();
            return(tr.idTransaction);
        }
Beispiel #13
0
        public ActionResult Create([Bind(Include = "idAge,imageAge,rangeAges")] AGE aGE)
        {
            if (ModelState.IsValid)
            {
                db.AGEs.Add(aGE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aGE));
        }
Beispiel #14
0
        public ActionResult Create([Bind(Include = "dateDay,terminalId,beginningCash,endCash")] CASH_BOTTOM_DAY cASH_BOTTOM_DAY)
        {
            if (ModelState.IsValid)
            {
                db.CASH_BOTTOM_DAY.Add(cASH_BOTTOM_DAY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.terminalId = new SelectList(db.TERMINALs, "idTerminal", "nameTerminal", cASH_BOTTOM_DAY.terminalId);
            return(View(cASH_BOTTOM_DAY));
        }
Beispiel #15
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));
        }
Beispiel #16
0
        public void UpdateTransactionMessageLanguage(int transacId, int languageMessage)
        {
            List <TRANSACTIONS_MESSAGE> messages = GetListTransactionMessage(transacId);

            foreach (var item in messages)
            {
                if (item.languageMessage != languageMessage)
                {
                    item.languageMessage = languageMessage;
                }
            }
            db.SaveChanges();
        }
Beispiel #17
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));
        }
Beispiel #18
0
 public void CreateCashDay(DateTime date, int terminalid, decimal beginCash)
 {
     // at the beginning endCash = 0
     db.CASH_BOTTOM_DAYs.Add(new CASH_BOTTOM_DAY {
         dateDay = date, terminalId = terminalid, beginningCash = beginCash, endCash = 0
     });
     db.SaveChanges();
 }
Beispiel #19
0
        public void CreatePayment(decimal tot, int methodP, int numTransaction)
        {
            PAYMENT p = new PAYMENT {
                amount = tot, momentPay = DateTime.Now, paymentMethodId = methodP, transactionId = numTransaction
            };

            db.PAYMENTs.Add(p);
            db.SaveChanges();
        }
Beispiel #20
0
        public ActionResult DeleteConfirmed(TRANSACTIONS tr, int id)
        {
            TRANSACTIONS transaction = db.TRANSACTIONSs.Find(id);

            if (tr.cancelDescritpion != null)
            {
                transaction.cancelDescritpion = tr.cancelDescritpion;
                transaction.statusId          = db.STATUSs.Where(s => s.nameStatus == "deleted").Select(st => st.idStatus).Single();
                db.Entry(transaction).State   = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.noReason = "Un motif est obligatoire";
            return(View(transaction));
        }
Beispiel #21
0
 public ActionResult Create(HeroViewModel vmodel)
 {
     if (ModelState.IsValid)
     {
         //Check if nameHero have min  1 value
         IList <HERO_TRANSLATION> heroesT = vmodel.HeroesTrans;
         bool nameHeroIsValid             = TranslationBL.CheckIfMinOneValued(heroesT);
         if (nameHeroIsValid)
         {
             //Check if Hero exist by nameHero before create
             bool nameExist = TranslationBL.CheckIfNameExist(heroesT);
             if (!nameExist)
             {
                 HERO hero = new HERO
                 {
                     imageHero = vmodel.ImageHero
                 };
                 db.HEROs.Add(hero);
                 db.SaveChanges();
                 int id    = hero.idHero;
                 int count = heroesT.Count();
                 //Check if nameHero isUniversal
                 bool isUniversal = TranslationBL.CheckIfUniversal(heroesT);
                 if (isUniversal)
                 {
                     for (int i = 0; i < heroesT.Count(); i++)
                     {
                         if (heroesT[i].nameHero != null)
                         {
                             heroesT[i].heroId = id;
                             //change language with universal
                             heroesT[i].languageId = LanguageBL.FindIdLanguageByShortForm("all");
                         }
                         else
                         {
                             heroesT.Remove(heroesT[i]);
                             i--;
                         }
                     }
                 }
                 else
                 {
                     foreach (var item in heroesT)
                     {
                         item.heroId = id;
                     }
                 }
                 db.HERO_TRANSLATIONs.AddRange(heroesT);
                 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!";
         }
     }
     vmodel.ListLang = LanguageBL.FindLanguageListWithoutUniversal();
     return(View(vmodel));
 }
Beispiel #22
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));
        }