//update //[HttpPut] public IHttpActionResult PutAnEmployee(DataViewModel s) { if (!ModelState.IsValid) { return(BadRequest("Not a valid data")); } using (var ctx = new SLKDatabaseEntities()) { var existingStudent = ctx.registrations.Where(m => m.SlNo == s.SlNo).FirstOrDefault <registration>(); if (existingStudent != null) { existingStudent.UserName = s.UserName; existingStudent.EmailId = s.EmailId; existingStudent.Password = s.Password; existingStudent.ConfirmPassword = s.ConfirmPassword; ctx.SaveChanges(); } else { return(NotFound()); } } return(Ok()); }
public ActionResult Add(detail post) { if (ModelState.IsValid) { using (SLKDatabaseEntities db = new SLKDatabaseEntities()) { db.details.Add(new detail { FirstName = post.FirstName, MiddleName = post.MiddleName, LastName = post.LastName, PhoneNumber = post.PhoneNumber, Gender = post.Gender, DateOfBirth = post.DateOfBirth, EmailID = post.EmailID, Address = post.Address, City = post.City, ZipCode = post.ZipCode, State = post.State, Country = post.Country, Department = post.Department, TenthBoard = post.TenthBoard, TenthMarks = post.TenthMarks, TwelfthBoard = post.TwelfthBoard, TwelfthMarks = post.TwelfthMarks, }); db.SaveChanges(); } ModelState.Clear(); } return(View()); }
public ActionResult Create([Bind(Exclude = "UserId")] detail slk) { try { entity.details.Add(slk); entity.SaveChanges(); return(RedirectToAction("Home")); } catch { return(View()); } }
public ActionResult Delete(detail Post) { if (ModelState.IsValid) { using (SLKDatabaseEntities db = new SLKDatabaseEntities()) { db.Entry(Post).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Home", "Home")); } } return(View(Post)); }
public IHttpActionResult DeleteEmployee(int id) { if (id <= 0) { return(BadRequest("Not a valid student id")); } using (var ctx = new SLKDatabaseEntities()) { var student = ctx.registrations .Where(s => s.SlNo == id) .FirstOrDefault(); ctx.Entry(student).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } return(Ok()); }
public IHttpActionResult PostNewEmployee(DataViewModel s) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } using (var ctx = new SLKDatabaseEntities()) { ctx.registrations.Add(new registration() { UserName = s.UserName, EmailId = s.EmailId, Password = s.Password, ConfirmPassword = s.ConfirmPassword }); ctx.SaveChanges(); } return(Ok()); }
//[AcceptVerbs("POST")] public IHttpActionResult Post1(DataViewModel student) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } using (var ctx = new SLKDatabaseEntities()) { ctx.registrations.Add(new registration() { SlNo = student.SlNo, UserName = student.UserName, EmailId = student.EmailId, Password = student.Password, ConfirmPassword = student.ConfirmPassword, }); ctx.SaveChanges(); } return(Ok()); }