예제 #1
0
        public ActionResult Create([Bind(Include = "Id,Name")] Program program)
        {
            if (ModelState.IsValid)
            {
                db.Programs.Add(program);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(program));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,First_name,Last_name,Program_id")] Faculty faculty)
        {
            if (ModelState.IsValid)
            {
                db.Faculties.Add(faculty);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Program_id = new SelectList(db.Programs, "Id", "Name", faculty.Program_id);
            return(View(faculty));
        }
 public IHttpActionResult Post([FromBody] Customer customer)
 {
     try
     {
         _context.Customers.Add(customer);
         _context.SaveChanges();
         return(Ok(customer.Id));
     }
     catch (Exception e)
     {
         return(InternalServerError(e));
     }
 }