public ActionResult VerifyAccount(string id) { bool Status = false; using (nlbdataEntities1 dc = new nlbdataEntities1()) { dc.Configuration.ValidateOnSaveEnabled = false; var v = dc.NBA_SYS_Users.Where(a => a.sys_VerificationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.sys_IsEmailVerified = true; dc.SaveChanges(); Status = true; } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = Status; return(View()); }
public ActionResult Create([Bind(Include = "AGWY_ID,name,surname,known_as,gender,race,type_of_identification,idno,dateOfbirth,place_of_birth,maiden_name,address,town_village,uic,email,phone_number,alternative__number,alternative_number_relationship,attended_school,name_of_school,higest_grade_passed,currrent_occupation,safe_place,approval_flag,concent_flag,mimetype,imagedata,home_language,reg_date,last_updated,last_login,status,ID,SEMESTER_ID,SYS_USER_ID,DOCUMENT_ID,RISK_ID,Core_ID")] NBA_Agwy nBA_Agwy) { if (ModelState.IsValid) { db.NBA_Agwy.Add(nBA_Agwy); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Core_ID = new SelectList(db.NBA_Core, "CORE_ID", "description", nBA_Agwy.Core_ID); ViewBag.DOCUMENT_ID = new SelectList(db.NBA_Documents, "DOCUMENT_ID", "doc_name", nBA_Agwy.DOCUMENT_ID); ViewBag.RISK_ID = new SelectList(db.NBA_RiskAssessment, "RISK_ID", "risk_description", nBA_Agwy.RISK_ID); ViewBag.SEMESTER_ID = new SelectList(db.NBA_SemesterMaintenance, "SEMESTER_ID", "semester_name", nBA_Agwy.SEMESTER_ID); ViewBag.ID = new SelectList(db.NBA_PR, "ID", "PR_SR_ID", nBA_Agwy.ID); return(View(nBA_Agwy)); }
public ActionResult DeleteConfirmed(int id) { NBA_Agwy nBA_Agwy = db.NBA_Agwy.Find(id); db.NBA_Agwy.Remove(nBA_Agwy); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteEmployee(int id) { bool status = false; using (nlbdataEntities1 dc = new nlbdataEntities1()) { var v = dc.NBA_Agwy.Where(a => a.AGWY_ID == id).FirstOrDefault(); if (v != null) { dc.NBA_Agwy.Remove(v); dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }
public ActionResult Save(NBA_Agwy emp) { bool status = false; if (ModelState.IsValid) { using (nlbdataEntities1 dc = new nlbdataEntities1()) { if (emp.AGWY_ID > 0) { //Edit var v = dc.NBA_Agwy.Where(a => a.AGWY_ID == emp.AGWY_ID).FirstOrDefault(); if (v != null) { v.name = emp.name; v.surname = emp.surname; v.known_as = emp.known_as; v.gender = emp.gender; v.age = emp.age; v.type_of_identification = emp.type_of_identification; v.idno = emp.idno; v.dateOfbirth = emp.dateOfbirth; v.town_village_address = emp.town_village_address; v.maiden_name = emp.maiden_name; v.street_name = emp.street_name; v.town_village = emp.town_village; v.uic = emp.uic; } } else { //Save dc.NBA_Agwy.Add(emp); } dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }
public ActionResult Registration([Bind(Exclude = "sys_IsEmailVerified,sys_VerificationCode")] NBA_SYS_Users user) { bool Status = false; string message = ""; // // Model Validation if (!ModelState.IsValid) { #region //Email is already Exist var isExist = IsEmailExist(user.email); if (isExist) { ModelState.AddModelError("EmailExist", "Email already exist"); return(View(user)); } #endregion #region Generate Activation Code user.sys_VerificationCode = Guid.NewGuid(); #endregion #region Password Hashing user.password = Crypto.Hash(user.password); user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); // #endregion user.sys_IsEmailVerified = false; #region Save to Database using (nlbdataEntities1 dc = new nlbdataEntities1()) { dc.NBA_SYS_Users.Add(user); dc.SaveChanges(); //Send Email to User SendVerificationLinkEmail(user.email, user.sys_VerificationCode.ToString()); message = "Registration successfully done. Account activation link " + " has been sent to your email id:" + user.email; Status = true; } #endregion } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = Status; return(View(user)); }
// public ActionResult Edit([Bind(Include = "AGWY_ID,name,surname,known_as,gender,race,type_of_identification,idno,dateOfbirth,place_of_birth,maiden_name,address,town_village,uic,email,phone_number,alternative_number,alternative_number_relationship,attended_school,name_of_school,higest_grade_passed,currrent_occupation,approval_flag,concent_flag,mimetype,imagedata,home_language,reg_date,last_updated,last_login,status,ID,SEMESTER_ID,SYS_USER_ID,DOCUMENT_ID,Core_ID,messageInquiry,EntryPoint_ID,HighSchoolQuizz_ID,RISK_ID")] NBA_Agwy nBA_Agwy) public ActionResult Edit(NBA_Agwy nBA_Agwy) { if (ModelState.IsValid) { //db.Entry(nBA_Agwy).State = EntityState.Modified; //db.SaveChanges(); //return RedirectToAction("Index"); var db = new nlbdataEntities1(); //string dateofbirth=nBA_Agwy.dateOfbirth DateTime dob = Convert.ToDateTime(nBA_Agwy.dateOfbirth); string day = dob.ToString("dd/MM/yyyy"); //string day = dob.ToString(); //string day = nBA_Agwy.dateOfbirth.ToString(); //string uuic = nBA_Agwy.name.Substring(0, 2) + nBA_Agwy.maiden_name.Substring(0, 3) + nBA_Agwy.dateOfbirth.ToString().Substring(0, 8); string uuic = nBA_Agwy.name.Substring(0, 2) + nBA_Agwy.maiden_name.Substring(0, 3) + day.Substring(0, 2) + day.Substring(3, 2) + nBA_Agwy.town_village.Substring(0, 3); //r dbuic = db.NBA_Agwy.Where(x => x.uic.Substring(0, 15) == uuic).Select( n1 => n1.uic).FirstOrDefault(); //ar uic = db.NBA_Agwy.Where(x => x.uic.Substring(0, 15) == uuic).Select(n1 => n1.uic).FirstOrDefault(); //r uic1=(from var in db.NBA_Agwy where var.uic == nBA_Agwy.uic).select var.uic; //uic1.FirstOrDefault(); //tring dbui1 = dbuic.ToString(); var uiccount = db.NBA_Agwy.Where(x => x.uic == uuic).Select(n3 => n3.uic).Count(); int uiccounting = uiccount; if (uiccounting <= 1) { var uiccount1 = db.NBA_Agwy.Where(x => x.uic.Substring(0, 12) == uuic).Select(n3 => n3.uic).Count(); uiccounting = uiccount1; } // NBA_Agwy n = new NBA_Agwy(); NBA_Agwy n = db.NBA_Agwy.Where(x => x.AGWY_ID == nBA_Agwy.AGWY_ID).SingleOrDefault(); { n.name = nBA_Agwy.name; n.surname = nBA_Agwy.surname; n.known_as = nBA_Agwy.known_as; n.gender = nBA_Agwy.gender; //n.age = nBA_Agwy.age; n.type_of_identification = nBA_Agwy.type_of_identification; n.idno = nBA_Agwy.idno; n.reg_date = DateTime.Today; int useridsession = Convert.ToInt32(Session["UseriD"]); n.SYS_USER_ID = useridsession; n.house_number = nBA_Agwy.house_number; n.street_name = nBA_Agwy.street_name; n.town_village_address = nBA_Agwy.town_village_address; n.describe_living = nBA_Agwy.describe_living; n.dateOfbirth = nBA_Agwy.dateOfbirth; n.maiden_name = nBA_Agwy.maiden_name; n.name_of_school = nBA_Agwy.name_of_school; n.alternative_number = nBA_Agwy.alternative_number; n.alternative_number_relationship = nBA_Agwy.alternative_number_relationship; n.attended_school = nBA_Agwy.attended_school; n.currrent_occupation = nBA_Agwy.currrent_occupation; n.email = nBA_Agwy.email; n.EntryPoint_ID = nBA_Agwy.EntryPoint_ID; n.higest_grade_passed = nBA_Agwy.higest_grade_passed; n.HighSchoolQuizz_ID = nBA_Agwy.HighSchoolQuizz_ID; n.known_as = nBA_Agwy.known_as; n.messageInquiry = nBA_Agwy.messageInquiry; n.NBA_Grade = nBA_Agwy.NBA_Grade; n.NBA_Identification = nBA_Agwy.NBA_Identification; n.ID = nBA_Agwy.ID; n.town_village = nBA_Agwy.town_village; n.NBA_Occupation = nBA_Agwy.NBA_Occupation; //DateTime today = today(); string today = DateTime.Now.ToString("dd/MM/yyyy").Substring(6, 4); // string today = DateTime.Now.ToString().Substring(6, 4); //string day = dob.ToString("dd/MM/yyyy"); string srtyear = day.Substring(6, 4); int age = Convert.ToInt32(today) - Convert.ToInt32(srtyear); n.age = age.ToString(); if (uiccounting > 1 || uiccounting == 1) { if (uiccounting < 9) { n.uic = nBA_Agwy.name.Substring(0, 2) + nBA_Agwy.maiden_name.Substring(0, 3) + day.Substring(0, 2) + day.Substring(3, 2) + nBA_Agwy.town_village.Substring(0, 3) + "0" + (1 + uiccount).ToString(); } else { n.uic = nBA_Agwy.name.Substring(0, 2) + nBA_Agwy.maiden_name.Substring(0, 3) + day.Substring(0, 2) + day.Substring(3, 2) + nBA_Agwy.town_village.Substring(0, 3) + (1 + uiccount).ToString(); } } else { n.uic = nBA_Agwy.name.Substring(0, 2) + nBA_Agwy.maiden_name.Substring(0, 3) + day.Substring(0, 2) + day.Substring(3, 2) + nBA_Agwy.town_village.Substring(0, 3); } } db.Entry(n).State = EntityState.Modified; //db.SaveChanges(); //db.NBA_Agwy.Add(n); db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Index")); } ViewBag.Core_ID = new SelectList(db.NBA_Core, "CORE_ID", "description", nBA_Agwy.Core_ID); ViewBag.DOCUMENT_ID = new SelectList(db.NBA_Documents, "DOCUMENT_ID", "doc_name", nBA_Agwy.DOCUMENT_ID); ViewBag.EntryPoint_ID = new SelectList(db.NBA_Entry_Points, "ENTRY_ID", "description", nBA_Agwy.EntryPoint_ID); ViewBag.gender = new SelectList(db.NBA_Gender, "GenderID", "GenderType", nBA_Agwy.gender); ViewBag.higest_grade_passed = new SelectList(db.NBA_Grade, "Grade_ID", "Description", nBA_Agwy.higest_grade_passed); ViewBag.HighSchoolQuizz_ID = new SelectList(db.NBA_HighSchoolQuizz, "HighSchoolQuiz_ID", "Description", nBA_Agwy.HighSchoolQuizz_ID); ViewBag.type_of_identification = new SelectList(db.NBA_Identification, "Identification_ID", "Description", nBA_Agwy.type_of_identification); ViewBag.messageInquiry = new SelectList(db.NBA_MessageID, "MessageID", "Description", nBA_Agwy.messageInquiry); ViewBag.currrent_occupation = new SelectList(db.NBA_Occupation, "Occupation_ID", "Description", nBA_Agwy.currrent_occupation); ViewBag.RISK_ID = new SelectList(db.NBA_RiskAssessment, "RISK_ID", "risk_description", nBA_Agwy.RISK_ID); ViewBag.SEMESTER_ID = new SelectList(db.NBA_SemesterMaintenance, "SEMESTER_ID", "semester_name", nBA_Agwy.SEMESTER_ID); ViewBag.ID = new SelectList(db.NBA_PR, "ID", "PR_SR_ID", nBA_Agwy.ID); return(View(nBA_Agwy)); }