public IHttpActionResult PutStudentData(int id, StudentData studentData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentData.Id) { return(BadRequest()); } db.Entry(studentData).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentDataExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(tStudent student) { if (ModelState.IsValid) { db.tStudent.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create(tStudent student) { if (ModelState.IsValid) //確認所有驗證器都通過後會傳回true { db.tStudent.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); //當驗證不通過時,將表單的值保留必須將model當參數丟給view }
public ActionResult Create(tStudent stu) { //true = Module的驗證器,完全通過 if (ModelState.IsValid) { db.tStudent.Add(stu); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stu)); }
public ActionResult Create([Bind(Include = "fid,fdesc,fdate,fitme,femailid")] feedbackmaster feedbackmaster) { if (ModelState.IsValid) { db.feedbackmasters.Add(feedbackmaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feedbackmaster)); }
public ActionResult Create([Bind(Include = "sid,sname,fname,lname,emailid,password,gender,image,college,country,state,city")] studentMaster studentMaster) { if (ModelState.IsValid) { db.studentMasters.Add(studentMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentMaster)); }
public ActionResult Create([Bind(Include = "eid,ename,edate,subjectname,egroup")] exammaster exammaster) { if (ModelState.IsValid) { db.exammasters.Add(exammaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(exammaster)); }
public ActionResult Create([Bind(Include = "aid,adate,aurl,subjectname,description")] assignmentMaster assignmentMaster) { if (ModelState.IsValid) { db.assignmentMasters.Add(assignmentMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assignmentMaster)); }
public ActionResult Create([Bind(Include = "facid,facname,emailid,password")] facultymaster facultymaster) { if (ModelState.IsValid) { db.facultymasters.Add(facultymaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(facultymaster)); }
public string addCountryDetails(string CountryName, bool CountryIsEnabled) { try { CountryMaster countryMaster = new CountryMaster() { CountryName = CountryName, IsCountryEnabled = CountryIsEnabled }; db.CountryMasters.Add(countryMaster); db.SaveChanges(); } catch (Exception ex) { return("Error:" + ex.Message); } return("Country Details Add Successfuly!"); }
public int AddStudentRecord(tblStudentRecord model) { int id = 0; try { int count = _db.tblStudentRecords.Where(a => a.EmailId == model.EmailId || a.PhoneNumber == model.PhoneNumber).Count(); if (count == 0) { _db.tblStudentRecords.Add(model); _db.SaveChanges(); id = model.Id; } else { id = -1; } } catch (Exception a1) { } return(id); }
public ActionResult editProfile(string emailid, string name) { try { if (Session["adminDetails"] == null) { TempData["Error"] = "Please Login to Access Dashboard!"; return(RedirectToAction("login", "authentication")); } string sesname = Session["adminDetails"].ToString(); var data = db.adminMasters.Single(a => a.name == sesname); data.emailid = emailid; data.name = name; db.SaveChanges(); Session["adminDetails"] = name; TempData["Message"] = "Details Edit!"; } catch (Exception ex) { TempData["Error"] = ex.Message; } return(RedirectToAction("index")); }