Esempio n. 1
0
        public ActionResult AddNewCurrency(tblCurrency model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var symbol = model.CurrencyCode.ToUpper();

                    if (db.tblCurrencies.Any(o => o.CurrencyCode == symbol))
                    {
                        TempData["ResultError"] = "There is already currency with this code in database!";
                        return(RedirectToAction("AddNewCurrency"));
                    }

                    var currencyData = GetCurrencieExchangeRate(symbol);

                    if (isAllGood)
                    {
                        var value = currencyData.rates[symbol];

                        var tbl = new tblCurrency
                        {
                            CurrencyCode  = model.CurrencyCode,
                            CurrencyName  = model.CurrencyName,
                            CurrencyValue = Convert.ToDecimal(value),
                            UserName      = User.Identity.Name,
                            DateChanged   = DateTime.Now,
                            DateCreated   = DateTime.Now
                        };

                        db.tblCurrencies.Add(tbl);
                        db.SaveChanges();

                        return(RedirectToAction("ViewAllCurrencies"));
                    }
                }
                catch (Exception ex)
                {
                    SendExceptionToAdmin(ex.ToString());
                }
            }

            TempData["ResultError"] = "Something went wrong! ";
            return(View());
        }
Esempio n. 2
0
        public ActionResult AddNewCoupon(tblDiscount model, string Reservationtime)
        {
            DateTime?startDate, endDate;
            int      discount        = 0;
            string   reservationtime = Reservationtime;
            string   code            = GenericSymbols();

            if (ModelState.IsValid && !String.IsNullOrEmpty(reservationtime))
            {
                try
                {
                    startDate = Convert.ToDateTime(reservationtime.Split('-')[0].Trim());
                    endDate   = Convert.ToDateTime(reservationtime.Split('-')[1].Trim());
                    discount  = model.DiscountAmount;

                    var tbl = new tblDiscount
                    {
                        DiscountKey         = code,
                        DiscountAmount      = discount,
                        StartDateOfDiscount = startDate,
                        EndDateOfDiscount   = endDate,
                        UserName            = User.Identity.Name,
                        DateChanged         = DateTime.Now,
                        DateCreated         = DateTime.Now
                    };

                    db.tblDiscounts.Add(tbl);
                    db.SaveChanges();

                    TempData["ResultSuccess"] = "Success in adding new coupon!";

                    return(RedirectToAction("ViewAllCoupons"));
                }
                catch (Exception ex)
                {
                    TempData["ResultError"] = "Error in adding new coupon!";
                    SendExceptionToAdmin(ex.ToString());
                }
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }
Esempio n. 3
0
        public ActionResult AddToCard(string idProduct, ProductsViewModels models)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(PartialView("~/Views/Shared/_UserCard.cshtml", GetModelFromBasket()));
            }
            if (Request.IsAjaxRequest())
            {
                var user   = db.tblShoppers.Where(b => b.UserName == User.Identity.Name).FirstOrDefault();
                var basket = new BCG_DB.Entity.Store.tblShopingCart()
                {
                    IdShopper   = user.IdShopper,
                    IdProduct   = Convert.ToInt32(idProduct),
                    IdQuantity  = Convert.ToInt32(models.SelectedQuantity),
                    UserName    = User.Identity.Name,
                    DateChanged = DateTime.Now,
                    DateCreated = DateTime.Now
                };

                db.tblShopingCarts.Add(basket);
                db.SaveChanges();
            }
            return(PartialView("~/Views/Shared/_UserCard.cshtml", GetModelFromBasket()));
        }
Esempio n. 4
0
        public ActionResult DeleteReview(int id)
        {
            try
            {
                var tbl = db.tblCustomerReviews.Find(id);
                db.tblCustomerReviews.Remove(tbl);
                db.SaveChanges();
                TempData["ResultSuccess"] = "Success in deleting customer review!";
            }
            catch (Exception ex)
            {
                SendExceptionToAdmin(ex.ToString());
                TempData["ResultError"] = "Error in deleting!";
            }


            return(RedirectToAction("ViewAllReviews"));
        }