Пример #1
0
        public RedirectToRouteResult AddToOrder(string returnUrl)
        {
            TradeDBEntities _db = new TradeDBEntities();
                var NewOrder = Cart.lineCollection;
                SVTrade.Models.Order SetOrder = new SVTrade.Models.Order();

                foreach (var a in NewOrder)
                {
                    SetOrder.amount = a.Product.amount;
                    SetOrder.productID = a.Product.productID;
                    SetOrder.userID = MappingController.CurrentUserId;
                    SetOrder.orderDate = DateTime.Today;
                    SetOrder.finishDate = DateTime.Today.AddMonths(1);
                    SetOrder.statusDate = DateTime.Today;
                    SetOrder.canceled = false;
                    SetOrder.completed = false;
                    SetOrder.statusID = 1;
                    _db.Orders.Add(SetOrder);
                    _db.SaveChanges();

                }

            Cart.lineCollection.Clear();
            return RedirectToAction("Mapping", new { returnUrl });
        }
Пример #2
0
        public override string[] GetRolesForUser(string username)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return null;
            }

            var cacheKey = string.Format("{0}_role", username);
            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return (string[])HttpRuntime.Cache[cacheKey];
            }
            string[] roles = new string[]{};
            using (TradeDBEntities db = new TradeDBEntities())
                roles = (from a in db.UserGroups
                             join b in db.Users on a.userGroupID equals b.userGroupID
                             where b.contactPerson.Equals(username)
                             select a.name).ToArray<string>();
                if (roles.Count() > 0)
                {
                    HttpRuntime.Cache.Insert(cacheKey, roles, null, DateTime.Now.AddMinutes(_cacheTimeoutInMinute), Cache.NoSlidingExpiration);

                }

            return roles;
        }