Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,UserName,UserSurname,UserPhone,UserOrganization,FileName,FilePath,Status")] Order order)
        {
            if (id != order.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ID,TypeName,TypeSize,TypePrice")] AdvType advType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(advType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(advType));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("ID,MaterialName,MaterialSize,MaterialPrice")] Material material)
        {
            if (ModelState.IsValid)
            {
                _context.Add(material);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(material));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("ID,Login,Password")] UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User();
                model.Apply(user);

                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Esempio n. 5
0
        public async Task <IActionResult> Login([Bind("Login, Password, ReturnUrl")] AuthViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _context.Users
                           .Where(u => u.Login == model.Login && u.PasswordHash == CoreEditor.Models.User.HashPassword(model.Password))
                           .FirstOrDefaultAsync();

                if (user != null)
                {
                    await Authenticate(model.Login);

                    //return Redirect("../Home/Index");
                    if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl))
                    {
                        return(Redirect(model.ReturnUrl));
                    }
                    else
                    {
                        return(Redirect("../Home/Index"));
                    }
                }
                else
                {
                    ModelState.AddModelError(
                        string.Empty,
                        "Неверное имя пользователя или пароль"
                        );
                }

                await _context.SaveChangesAsync();
            }
            return(View(model));
        }