Esempio n. 1
0
        public ActionResult Post([FromBody] Employees employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Add(employee);
            _context.SaveChanges();
            return(Ok());
        }
        public async Task <IActionResult> Create([Bind("DepartmentId,DepartmentTitle")] Departments departments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(departments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(departments));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("JobId,JobTitle")] Jobs jobs)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobs);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobs));
        }
Esempio n. 4
0
 public void AddRelatedPerson(PersonModel person, PersonModel relatedPerson, int relationTypeId)
 {
     using (var db = new PersonDBContext())
     {
         var model = new PersonToPerson();
         model.PersonId        = person.Id;
         model.RelatedPersonId = relatedPerson.Id;
         model.RelationTypeId  = relationTypeId;
         db.Add(model);
         db.SaveChanges();
     }
 }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("PersonelId,FirstName,LastName,Salary,JobId,DeparmentId")] Employees employees)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employees);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DeparmentId"] = new SelectList(_context.Departments, "DepartmentId", "DepartmentId", employees.DeparmentId);
            ViewData["JobId"]       = new SelectList(_context.Jobs, "JobId", "JobId", employees.JobId);
            return(View(employees));
        }
Esempio n. 6
0
        public int CreatePerson(PersonModel person)
        {
            using (var db = new PersonDBContext())
            {
                var model = new Person
                {
                    FirstName      = person.FirstName,
                    LastName       = person.LastName,
                    PersonalNumber = person.PersonalNumber,
                    GenderiD       = person.GenderiD,
                    CityId         = person.CityId,
                    BirthDate      = person.BirthDate,
                    ImagePath      = person.ImagePath
                };

                db.Add(model);
                db.SaveChanges();

                return(model.Id);
            }
        }
Esempio n. 7
0
 public void Add(Person newperson)
 {
     context.Add(newperson);
     context.SaveChanges();
 }