Exemplo n.º 1
0
        //POST api/class
        public IHttpActionResult CreateClass(Class pClass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _context.Classes.Add(pClass);
            _context.SaveChanges();
            return(Created(new Uri(Request.RequestUri + "/" + pClass.ID_Class), pClass));
        }
Exemplo n.º 2
0
        public IHttpActionResult CreateUniversity(University university)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _context.Universities.Add(university);
            _context.SaveChanges();
            return(Created(new Uri(Request.RequestUri + "/" + university.ID_Uni), university));
        }
Exemplo n.º 3
0
        public IHttpActionResult CreateDepartment(Department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _context.Departments.Add(department);
            _context.SaveChanges();

            return(Created(new Uri(Request.RequestUri + "/" + department.ID_Dep), department));
        }
Exemplo n.º 4
0
        public IHttpActionResult CreateStudent(Student student)
        {
            if (!ModelState.IsValid)
            {
                //throw new HttpResponseException(HttpStatusCode.BadRequest);
                return(BadRequest());
            }

            //var student = Mapper.Map<StudentDTO, Student>(studentDTO);
            _context.Students.Add(student);
            _context.SaveChanges();
            return(Created(new Uri(Request.RequestUri + "/" + student.ID_Stu), student));
        }
Exemplo n.º 5
0
        public ActionResult Delete(Student student)
        {
            string         id       = student.ID_Stu;
            List <Student> students = _context.Students.ToList();

            foreach (var stu in students)
            {
                if (stu.ID_Stu == id)
                {
                    _context.Students.Remove(stu);
                    _context.SaveChanges();
                    break;
                }
            }
            return(RedirectToAction("ListOut", "Student"));
        }
Exemplo n.º 6
0
        public ActionResult CreateUniversity(University university)
        {
            if (!ModelState.IsValid)
            {
                var temp = university;
                return(View("NewUniversity", temp));
            }

            try
            {
                _context.Universities.Add(university);
                _context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                Console.WriteLine(e);
            }


            return(RedirectToAction("ListOutUniversity", "University"));
        }
Exemplo n.º 7
0
        public ActionResult CreateClass(DepClassModel depClass)
        {
            if (!ModelState.IsValid)
            {
                var temp = depClass;
                return(View("NewClass", temp));
            }
            Class nClass = depClass.newClass;

            try
            {
                _context.Classes.Add(nClass);
                _context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                Console.WriteLine(e);
            }


            return(RedirectToAction("ListOutClass", "Class"));
        }
Exemplo n.º 8
0
        public ActionResult CreateDepartment(UniDepModel uniDep)
        {
            if (!ModelState.IsValid)
            {
                var temp = uniDep;
                return(View("NewDepartment", temp));
            }
            Department nDep = uniDep.department;

            try
            {
                _context.Departments.Add(nDep);
                _context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                Console.WriteLine(e);
            }


            return(RedirectToAction("ListOutDepartment", "Department"));
        }