Пример #1
0
        public virtual async Task <T> Create(T obj)
        {
            _context.Add(obj);
            await _context.SaveChangesAsync();

            return(obj);
        }
        public async Task <IActionResult> Create([Bind("EmployeeId,FirstName,LastName,DateBirthday,Inn")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public async Task <IActionResult> Create(long id, string familyName, string name, string surname, IFormFile image, DateTime birthDate)
        {
            string path = await UploadImg(image);

            HumanResourcesModel staffMember = new HumanResourcesModel
            {
                // fill all staff's fields
                FamilyName = familyName,
                Name       = name,
                Surname    = surname,
                BirthDate  = birthDate,
                Image      = path
            };

            //create and save staffmember in database
            _context.Add(staffMember);
            //_context.StaffMember.Update(staffMember);
            await _context.SaveChangesAsync();

            return(RedirectToAction("StaffList"));
        }