Exemplo n.º 1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var application = await _context.Application.FindAsync(id);

            _context.Application.Remove(application);
            await _context.SaveChangesAsync();

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Name,LogoUrl,ImageUrl,Location,WorkingHours,TelephoneNumber,Email,Description,SubCategoryId")] Shop shop)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { id = TempData["CategoryId"] }));
            }
            ViewData["SubCategoryId"] = new SelectList(_context.Subcategory, "Id", "Name", shop.SubCategoryId);
            return(View(shop));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name,CategoryId")] Subcategory subcategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subcategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Name", subcategory.CategoryId);
            return(View(subcategory));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,ShopId,EmployeeId,StartDate")] Employment employment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "FullName", employment.EmployeeId);
            ViewData["ShopId"]     = new SelectList(_context.Shop, "Id", "Name", employment.ShopId);
            return(View(employment));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create(Employee entry, IFormFile cvUrl)
        {
            Employee employee = new Employee
            {
                FirstName  = entry.FirstName,
                LastName   = entry.LastName,
                Email      = entry.Email,
                PictureUrl = entry.PictureUrl,
                CVUrl      = UploadFile(cvUrl)
            };

            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public async Task <IActionResult> Edit(int id, Employment entry)
        {
            if (id != entry.Id)
            {
                return(NotFound());
            }
            var employment = _context.Employment.FirstOrDefault(s => s.Id == id);

            if (employment == null)
            {
                return(NotFound());
            }
            AppUser user = await userManager.GetUserAsync(User);

            if (employment.EmployeeId != user.EmployeeId)
            {
                return(RedirectToAction("AccessDenied", "Account", null));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    employment.Comment = entry.Comment;
                    _context.Update(employment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmploymentExists(employment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(MyEmployments), new { id = employment.EmployeeId }));
            }
            ViewData["ShopId"] = new SelectList(_context.Shop, "Id", "Name", employment.ShopId);
            return(View(employment));
        }