示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Adress,Phone,PositionId,Info,Reward")] Staff staff)
        {
            if (id != staff.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staff);
                    await _context.SaveChangesAsync();

                    _cache.Clean();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffExists(staff.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PositionId"] = new SelectList(_context.Positions, "Id", "Id", staff.PositionId);
            return(View(staff));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,PositionName")] Position position)
        {
            if (id != position.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(position);
                    await _context.SaveChangesAsync();

                    _cache.Clean();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PositionExists(position.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(position));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GroupName,StaffId,CountOfChildren,YearOfCreation,TypeId")] Group @group)
        {
            if (id != @group.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@group);
                    await _context.SaveChangesAsync();

                    _cache.Clean();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupExists(@group.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StaffId"] = new SelectList(_context.Staff, "Id", "Id", @group.StaffId);
            ViewData["TypeId"]  = new SelectList(_context.GroupTypes, "Id", "Id", @group.TypeId);
            return(View(@group));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,BirthDate,Gender,ParentId,Adress,GroupId,Note,OtherGroup")] Child child)
        {
            if (id != child.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(child);
                    await _context.SaveChangesAsync();

                    _cache.Clean();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChildExists(child.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"]  = new SelectList(_context.Groups, "Id", "Id", child.GroupId);
            ViewData["ParentId"] = new SelectList(_context.Parents, "Id", "Id", child.ParentId);
            return(View(child));
        }
示例#5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Mfullname,Ffullname")] Parent parent)
        {
            if (id != parent.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(parent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParentExists(parent.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(parent));
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NameOfType,Note")] GroupType groupType)
        {
            if (id != groupType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(groupType);
                    await _context.SaveChangesAsync();

                    _cache.Clean();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupTypeExists(groupType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(groupType));
        }