Esempio n. 1
0
        public ActionResult CancelOrder(Guid reference)
        {
            log.Info("Action /Orders/OrderNow has been fired.");
            Order order = db.Order.Find(reference);

            if (order == null)
            {
                return(View("ErrorPage"));
            }
            if (!order.CurrentState.Equals("SUBMITTED"))
            {
                return(View("ErrorPage"));
            }
            order.CurrentState    = "CANCELED";
            db.Entry(order).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("OrderTokens"));
        }
        public ActionResult Edit([Bind(Include = "ItemsPerPage,SilverPack,GoldPack,PlatinumPack,ValueToken,Currency")] InformationsForAdministrator informationsForAdministrator)
        {
            log.Info("POST action /InformationsForAdministrators/Edit has been fired.");

            if (ModelState.IsValid)
            {
                db.Entry(informationsForAdministrator).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(View(informationsForAdministrator));
        }
Esempio n. 3
0
        private void createRolesAndUsers()
        {
            ApplicationDbContext context = new ApplicationDbContext();

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            if (!roleManager.RoleExists("Administrator"))
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                role.Name = "Administrator";
                roleManager.Create(role);

                var user = new ApplicationUser();
                user.UserName       = "******";
                user.Email          = "*****@*****.**";
                user.FirstName      = "Tijana";
                user.LastName       = "Jovanovic";
                user.Role           = 1;
                user.NumberOfTokens = 0;

                string adminPassword = "******";

                var admin = UserManager.Create(user, adminPassword);

                if (admin.Succeeded)
                {
                    var adminAdded = UserManager.AddToRole(user.Id, "Administrator");
                }
            }
            Auctions db = new Auctions();

            if (!db.InformationsForAdministrator.Any())
            {
                var info = new InformationsForAdministrator();
                info.Currency     = "RSD";
                info.GoldPack     = 50;
                info.SilverPack   = 30;
                info.PlatinumPack = 100;
                info.ItemsPerPage = 10;
                info.ValueToken   = 10;

                db.InformationsForAdministrator.Add(info);
                db.SaveChanges();
            }


            if (!roleManager.RoleExists("RegularUser"))
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                role.Name = "RegularUser";
                roleManager.Create(role);
            }
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "IdAuction,Name,Image,Duration,StartingPrice")] Auction auction, HttpPostedFileBase file)
        {
            log.Info("POST action /Auction/Create has been fired.");
            if (ModelState.IsValid)
            {
                auction.IdAuction    = Guid.NewGuid();
                auction.CurrentPrice = auction.StartingPrice;
                auction.State        = "READY";
                auction.Created      = DateTime.Now;
                auction.IdOwner      = User.Identity.GetUserId();
                auction.IdWinner     = null;
                if (file != null)
                {
                    using (System.IO.MemoryStream ms = new MemoryStream())
                    {
                        file.InputStream.CopyTo(ms);
                        auction.Image = ms.GetBuffer();
                    }
                }
                db.Auction.Add(auction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(auction));
        }