Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,OrderNumber")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Name,LastName,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Comment(CommentsViewModel cvm)
        {
            bool approve     = false;
            User currentUser = await iSecure.GetCurrentUser(User);

            if (User.IsInRole(nameof(Roles.Admin)) || User.IsInRole(nameof(Roles.Manager)))
            {
                approve = true;
            }
            if (cvm.MainCommentId == 0)
            {
                MainComment commentItem = new MainComment()
                {
                    CommentMessage = cvm.Message,
                    UserId         = currentUser.Id,
                    ProductId      = cvm.ProductId,
                    Approved       = approve
                };

                EshopDBContext.Add(commentItem);

                await EshopDBContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Detail), new { id = commentItem.ProductId }));
            }
            else
            {
                SubComment commentItem = new SubComment()
                {
                    MainCommentId  = cvm.MainCommentId,
                    CommentMessage = cvm.Message,
                    UserId         = currentUser.Id,
                    Approved       = approve
                };
                EshopDBContext.Add(commentItem);
                await EshopDBContext.SaveChangesAsync();

                commentItem.MainComment = EshopDBContext.MainComments.Where(c => c.ID == commentItem.MainCommentId).FirstOrDefault();
                return(RedirectToAction(nameof(Detail), new { id = commentItem.MainComment.ProductId }));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("OrderNumber,TotalPrice,UserId,ID,DateTimeCreated")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", order.UserId);
            return(View(order));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("OrderID,ProductID,Amount,Price,ID,DateTimeCreated")] OrderItem orderItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderID"]   = new SelectList(_context.Order, "ID", "OrderNumber", orderItem.OrderID);
            ViewData["ProductID"] = new SelectList(_context.Products, "ID", "DataTarget", orderItem.ProductID);
            return(View(orderItem));
        }