Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Position position)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "Positions"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(position);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(position));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,MiddleName,BirthDate,Gender,Address,Phone,PassportData,Discount")] Client client)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "Clients"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
        public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,MiddleName,BirthDate,PositionId")] Employee employee)
        {
            if (!User.IsInRole(Areas.Identity.Roles.Admin))
            {
                return(RedirectToAction("Index", "Employees"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                _caching.Clean();
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Positions"] = new SelectList(_context.Positions, "Id", "Name", employee.PositionId);
            return(View(employee));
        }