Exemplo n.º 1
0
        public IActionResult Create()
        {
            Claim  userIdClaim;
            String userIdValue    = "";
            var    claimsIdentity = User.Identity as ClaimsIdentity;

            if (claimsIdentity != null)
            {
                // the principal identity is a claims identity.
                // now we need to find the NameIdentifier claim
                userIdClaim = claimsIdentity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier);

                if (userIdClaim != null)
                {
                    userIdValue = userIdClaim.Value;
                }
            }
            var cart      = SessionHelper.GetObjectFromJson <List <OrderItem> >(HttpContext.Session, "cart");
            var orderHead = new Order {
                OrderItems       = cart,
                OrderStatecodeId = 1,
                UserId           = userIdValue, //"6a4c72ef-e663-4ad9-af76-d350aa919433",
            };

            _context.Add(orderHead);
            _context.SaveChanges();
            cart.Clear();
            SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Link,Description,Local_id")] Image image)
        {
            if (ModelState.IsValid)
            {
                _context.Add(image);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(image));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] OrderStatecode orderStatecode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderStatecode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderStatecode));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Color color)
        {
            if (ModelState.IsValid)
            {
                _context.Add(color);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(color));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,ImageId")] Costumer costumer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(costumer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ImageId"] = new SelectList(_context.Images, "Id", "Link", costumer.ImageId);
            return(View(costumer));
        }
        public async Task <IActionResult> Create([Bind("Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount,FirstName,LastName,RoleId,LocalId")] AspNetUser aspNetUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aspNetUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocalId"] = new SelectList(_context.Locals, "Id", "Address", aspNetUser.LocalId);
            ViewData["RoleId"]  = new SelectList(_context.Roles, "Id", "Name", aspNetUser.RoleId);
            return(View(aspNetUser));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,UserId,OrderStatecodeId")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderStatecodeId"] = new SelectList(_context.OrderStatecodes, "Id", "Name", order.OrderStatecodeId);
            ViewData["UserId"]           = new SelectList(_context.AspNetUsers, "Id", "Id", order.UserId);
            return(View(order));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Id,ImageId,LocalId,Name,Description,Price,CategoryId")] Item item)
        {
            if (ModelState.IsValid)
            {
                _context.Add(item);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", item.CategoryId);
            ViewData["ImageId"]    = new SelectList(_context.Images, "Id", "Link", item.ImageId);
            ViewData["LocalId"]    = new SelectList(_context.Locals, "Id", "Address", item.LocalId);
            return(View(item));
        }