public ActionResult Edit([Bind(Include = "Emp_id,Fname,Lname,DOB,ContactNo,Email_id,PAN,Address,Password,Designation,Salary")] EmpDetail empDetail) { if (ModelState.IsValid) { var currentPerson = db.EmpDetails.FirstOrDefault(p => p.Emp_id.Equals(empDetail.Emp_id)); if (currentPerson == null) { return(HttpNotFound()); } currentPerson.Fname = empDetail.Fname; currentPerson.Lname = empDetail.Lname; currentPerson.DOB = empDetail.DOB; currentPerson.Address = empDetail.Address; currentPerson.PAN = empDetail.PAN; currentPerson.Password = empDetail.Password; currentPerson.ContactNo = empDetail.ContactNo; currentPerson.Email_id = empDetail.Email_id; // Id and Password are not updated. db.SaveChanges(); return(RedirectToAction("Index")); } return(View(empDetail)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.FirstName + " " + model.LastName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>"); //ViewBag.Link = callbackUrl; //return View("DisplayEmail"); #region Custom User details EmpDetail newEmpDetails = new EmpDetail(); newEmpDetails.EmpId = user.Id; newEmpDetails.FirstName = model.FirstName; newEmpDetails.LastName = model.LastName; LMSEntities db = new LMSEntities(); db.EmpDetails.Add(newEmpDetails); db.SaveChanges(); return(RedirectToAction("Index", "Home")); #endregion } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult DeleteConfirmed(int id) { EmpDetail empDetail = db.EmpDetails.Find(id); db.EmpDetails.Remove(empDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult HtmlHelperExample() { EmpDetail db = new EmpDetail(); EmployeeModel emp = new EmployeeModel(); emp.EmpName = "Vinay"; ViewBag.Countries = new SelectList(db.getEmployees(), "EmpId", "EmpName", 35035); return(View(emp)); }
public ActionResult Delete(int id) { using (EmployeeEntities ee = new EmployeeEntities()) { EmpDetail ed = ee.EmpDetails.Where(x => x.EmployeeID == id).FirstOrDefault <EmpDetail>(); ee.EmpDetails.Remove(ed); ee.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit([Bind(Include = "Emp_id,Fname,Lname,DOB,ContactNo,Email_id,PAN,Address,Password,Designation,Salary")] EmpDetail empDetail) { if (ModelState.IsValid) { db.Entry(empDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(empDetail)); }
public ActionResult Edit([Bind(Include = "Empid,Empname,EmpSalary")] EmpDetail empDetail) { if (ModelState.IsValid) { db.Entry(empDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(empDetail)); }
public ActionResult Create([Bind(Include = "Empid,Empname,EmpSalary")] EmpDetail empDetail) { if (ModelState.IsValid) { db.EmpDetails.Add(empDetail); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(empDetail)); }
// GET: EmpDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpDetail empDetail = db.EmpDetails.Find(id); if (empDetail == null) { return(HttpNotFound()); } return(View(empDetail)); }
public string DeleteEmp(int id) { string msg = string.Empty; try { EmpDetail empDetails = mvcDemoEntities.EmpDetails.Find(id); mvcDemoEntities.EmpDetails.Remove(empDetails); mvcDemoEntities.SaveChanges(); msg = "Record deleted successfully"; } catch (Exception ex) { msg = ex.Message; } return(msg); }
public ActionResult Register([Bind(Include = "Emp_id,Fname,Lname,DOB,ContactNo,Email_id,PAN,Address,Password,Designation,Salary")] EmpDetail empDetail) { if (ModelState.IsValid) { Session["RegName"] = empDetail.Fname.ToString() + empDetail.Lname.ToString(); db.EmpDetails.Add(empDetail); db.SaveChanges(); return(RedirectToAction("Register", "Login")); } else { ModelState.AddModelError("", "Sorry could not create your account,maybe email id already exists"); return(RedirectToAction("Register", "Login")); } }
public ActionResult AddOrEdit(EmpDetail emp) { using (EmployeeEntities ee = new EmployeeEntities()) { if (emp.EmployeeID == 0) { ee.EmpDetails.Add(emp); ee.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { ee.Entry(emp).State = EntityState.Modified; ee.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public string EditEmp(EmpDetail empDetail) { string msg = string.Empty; try { if (ModelState.IsValid) { mvcDemoEntities.Entry(empDetail).State = EntityState.Modified; mvcDemoEntities.SaveChanges(); msg = "Record updated successfully"; } } catch (Exception ex) { msg = ex.Message; } return(msg); }
public void Downloads(int?id) { if (id != null) { EmpDetail det = db.EmpDetails.Find(id); var sb = new StringBuilder(); sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", "Employee Id", "Employee Name", "Date Of Birth ", "Contact Number", "Email Id", "PAN", "Address", "Designation", "Salary", Environment.NewLine); sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", det.Emp_id, (det.Fname.ToString() + " " + det.Lname.ToString()), det.DOB.ToString().Substring(0, 11), det.ContactNo, det.Email_id.ToString(), det.PAN, det.Address, det.Designation, det.Salary, Environment.NewLine); var response = System.Web.HttpContext.Current.Response; response.BufferOutput = true; response.Clear(); response.ClearHeaders(); response.ContentEncoding = Encoding.Unicode; response.AddHeader("content-disposition", "attachment;filename=YourDetails.CSV "); response.ContentType = "text/plain"; response.Write(sb.ToString()); response.End(); } }
public ActionResult Index(EmpDetail objchk) { if (ModelState.IsValid) { using (EmployeeEntities db = new EmployeeEntities()) { var obj = db.EmpDetails.Where(a => a.Email_id.Equals(objchk.Email_id) && a.Password.Equals(objchk.Password)).FirstOrDefault(); if (obj != null) { Session["Emp_id"] = obj.Emp_id.ToString(); Session["Fname"] = obj.Fname.ToString(); return(RedirectToAction("Index", "EmpDetails")); } else { ModelState.AddModelError("", "The Email_id or password is incorrect"); } } } return(View(objchk)); }
public String Create([Bind(Exclude = "EmployeeId")] EmpDetail empDetail) { string msg = string.Empty; try { if (ModelState.IsValid) { mvcDemoEntities.EmpDetails.Add(empDetail); mvcDemoEntities.SaveChanges(); msg = "Record added successfully"; } else { msg = "Enter valid data"; } } catch (Exception ex) { msg = ex.Message; } return(msg); }
public ActionResult Index(EmpDetail objm) { if (ModelState.IsValid) { using (EmployeeEntities db1 = new EmployeeEntities()) { var k = "*****@*****.**"; var obj1 = db1.EmpDetails.Where(b => k.Equals(objm.Email_id) && b.Password.Equals(objm.Password)).FirstOrDefault(); if (obj1 != null) { Session["name"] = obj1.Designation.ToString(); return(RedirectToAction("Index", "Admin")); } else { ModelState.AddModelError("", "Admin id or password is incorrect"); } } } return(View(objm)); }