public static int Deleteuserlist(int UserId, string Username) { try { using (var context = new IOASDBEntities()) { var query = (from D in context.tblUser where (D.UserId == UserId) select D.UserId).FirstOrDefault(); var user = context.tblUser.Where(U => U.UserId == UserId).FirstOrDefault(); if (user != null) { user.LastUpdateUserId = Common.GetUserid(Username); user.UPDTDateTS = DateTime.Now; user.Status = "InActive"; context.SaveChanges(); } var userrole = (from R in context.tblUserRole where (R.UserId == UserId) select R).ToList(); if (userrole.Count > 0) { context.tblUserRole.RemoveRange(userrole); context.SaveChanges(); } } return(4); } catch (Exception ex) { return(-1); } }
public static int UnmapProcessflowUser(List <ProcessFlowUser> selectedUser) { try { tblProcessGuidelineUser pglUser; int rowsAffected = 0; using (var context = new IOASDBEntities()) { if (selectedUser.Count > 0) { foreach (var user in selectedUser) { pglUser = context.tblProcessGuidelineUser.Where(s => s.UserId == user.UserId && s.ProcessGuidelineDetailId == user.ProcessGuidelineDetailId).FirstOrDefault(); context.Entry(pglUser).State = System.Data.Entity.EntityState.Deleted; rowsAffected = rowsAffected + context.SaveChanges(); } } } return(rowsAffected); } catch { return(-1); } }
public static int MapProcessflowUser(List <ProcessFlowUser> selectedUser) { try { int rowsAffected = 0; using (var context = new IOASDBEntities()) { if (selectedUser.Count > 0) { foreach (var user in selectedUser) { tblProcessGuidelineUser objIU = new tblProcessGuidelineUser(); objIU.ProcessGuidelineDetailId = user.ProcessGuidelineDetailId; objIU.UserId = user.UserId; context.tblProcessGuidelineUser.Add(objIU); rowsAffected = rowsAffected + context.SaveChanges(); } } } return(rowsAffected); } catch { return(-1); } }
public static bool ChangePasswordforuser(ChangePasswordModel model, String username) { try { using (var context = new IOASDBEntities()) { var oldpassword = Cryptography.Encrypt(model.OldPassword, "LFPassW0rd"); var userquery = context.tblUser.SingleOrDefault(dup => dup.UserName == username && dup.Password == oldpassword); if (userquery != null) { userquery.Password = Cryptography.Encrypt(model.NewPassword, "LFPassW0rd");; context.SaveChanges(); context.Dispose(); return(true); } else { return(false); } } } catch (Exception ex) { return(false); } }
public static int Resetpassword(ResetPassword model) { try { using (var context = new IOASDBEntities()) { var user = context.tblUser.Where(U => U.UserId == model.Userid).FirstOrDefault(); if (user != null) { string Username = model.Username; user.Password = Cryptography.Encrypt(model.NewPassword, "LFPassW0rd"); user.UPDTDateTS = DateTime.Now; user.LastUpdateUserId = Common.GetUserid(Username); context.SaveChanges(); context.Dispose(); return(1); } else { return(2); } } } catch (Exception ex) { return(-1); } }
/// <summary> /// This method when user login check user name and password /// </summary> /// <param name="logon"></param> /// <returns></returns> public static int Logon(LogOnModel logon) { try { using (var context = new IOASDBEntities()) { String Encpassword = Cryptography.Encrypt(logon.Password, "LFPassW0rd"); var userquery = context.tblUser.SingleOrDefault(dup => dup.UserName == logon.UserName && dup.Password == Encpassword && dup.Status == "Active"); if (userquery != null) { tblLoginDetails log = new tblLoginDetails(); log.UserId = userquery.UserId; log.LoginTime = DateTime.Now; context.tblLoginDetails.Add(log); context.SaveChanges(); return(userquery.UserId); } else { return(0); } } } catch (Exception ex) { return(-1); } }
public static int AddProcessFlow(ProcessFlowModel model) { using (var context = new IOASDBEntities()) { tblProcessGuidelineDetail objIU = new tblProcessGuidelineDetail(); objIU.ProcessGuidelineId = model.ProcessGuidelineid; objIU.FlowTitle = model.FlowTitle; context.tblProcessGuidelineDetail.Add(objIU); context.SaveChanges(); context.Dispose(); return(objIU.ProcessGuidelineDetailId); } }
/// <summary> /// Add department wise role authorization /// </summary> /// <param name="model">Role access form data</param> /// <returns></returns> public static List <Functionviewmodel> AddDepartmentrole(List <Functionviewmodel> model) { try { List <Functionviewmodel> listfunction = new List <Functionviewmodel>(); tblRoleaccess objrole = new tblRoleaccess(); using (var dbctx = new IOASDBEntities()) { var funid = model[0].Functionid; var deptid = model[0].Departmentid; var query = (from f in dbctx.tblRoleaccess where (f.FunctionId == funid && f.DepartmentId == deptid) select f).ToList(); if (query.Count > 0) { dbctx.tblRoleaccess.RemoveRange(query); dbctx.SaveChanges(); } } using (var context = new IOASDBEntities()) { if (model.Count > 0) { for (int i = 0; i < model.Count; i++) { if (model[i].Read == true) { objrole.RoleId = model[i].Roleid; objrole.FunctionId = model[i].Functionid; objrole.Read_f = model[i].Read; objrole.Add_f = model[i].Add; objrole.Delete_f = model[i].Delete; objrole.Approve_f = model[i].Approve; objrole.Update_f = model[i].Update; objrole.DepartmentId = model[i].Departmentid; objrole.Status = "Active"; context.tblRoleaccess.Add(objrole); context.SaveChanges(); } } } return(model); } } catch (Exception ex) { var msg = ex; return(model); } }
public static int DeletePGLWorkflow(int processguidlineworkflowId) { try { tblProcessGuidelineWorkFlow pglWF; int rowsAffected = 0; using (var context = new IOASDBEntities()) { pglWF = context.tblProcessGuidelineWorkFlow.Where(s => s.ProcessGuidelineWorkFlowId == processguidlineworkflowId).FirstOrDefault(); context.Entry(pglWF).State = System.Data.Entity.EntityState.Deleted; rowsAffected = context.SaveChanges(); } return(rowsAffected); } catch { return(-1); } }
public static int UpdateProcessFlow(ProcessFlowModel model) { tblProcessGuidelineDetail pgd; using (var context = new IOASDBEntities()) { pgd = context.tblProcessGuidelineDetail.Where(s => s.ProcessGuidelineDetailId == model.ProcessGuidelineDetailId).FirstOrDefault(); } if (pgd != null) { pgd.FlowTitle = model.FlowTitle; } using (var dbCtx = new IOASDBEntities()) { dbCtx.Entry(pgd).State = System.Data.Entity.EntityState.Modified; dbCtx.SaveChanges(); } return(model.ProcessGuidelineDetailId); }
public static int InsertProcessGuideline(ProcessGuideline model) { using (var context = new IOASDBEntities()) { tblProcessGuidelineHeader objIU = new tblProcessGuidelineHeader(); objIU.ProcessGuidelineId = model.ProcessGuidelineId; objIU.FunctionId = model.FunctionId; objIU.ProcessGuidelineTitle = model.ProcessName; if (model.ProcessGuidelineId == 0) { context.tblProcessGuidelineHeader.Add(objIU); } else { context.Entry(objIU).State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); context.Dispose(); return(objIU.ProcessGuidelineId); } }
public static int AddApproverDetails(ProcessFlowApproverList model) { try { using (var context = new IOASDBEntities()) { int rowsAffected = 0, pglWorkflowId = 0; if (model.ProcessguidlineworkflowId == 0) { tblProcessGuidelineWorkFlow objIU = new tblProcessGuidelineWorkFlow(); objIU.ProcessGuidelineId = model.processguidlineId; objIU.ProcessGuidelineDetailId = model.ProcessGuidelineDetailId; objIU.StatusId = model.StatusId; objIU.ApproverId = model.UserId; objIU.ApproverLevel = model.ApproverLevel; objIU.Approve_f = model.ApproveFlag; objIU.Reject_f = model.RejectFlag; objIU.Clarify_f = model.ClarifyFlag; objIU.Mark_f = model.MarkFlag; context.tblProcessGuidelineWorkFlow.Add(objIU); rowsAffected = context.SaveChanges(); pglWorkflowId = objIU.ProcessGuidelineWorkFlowId; } else { tblProcessGuidelineWorkFlow objupdate = new tblProcessGuidelineWorkFlow(); objupdate = context.tblProcessGuidelineWorkFlow.Where(M => M.ProcessGuidelineWorkFlowId == model.ProcessguidlineworkflowId).FirstOrDefault(); if (objupdate != null) { objupdate.ProcessGuidelineId = model.processguidlineId; objupdate.ProcessGuidelineDetailId = model.ProcessGuidelineDetailId; objupdate.StatusId = model.StatusId; objupdate.ApproverId = model.UserId; objupdate.ApproverLevel = model.ApproverLevel; objupdate.Approve_f = model.ApproveFlag; objupdate.Reject_f = model.RejectFlag; objupdate.Clarify_f = model.ClarifyFlag; objupdate.Mark_f = model.MarkFlag; rowsAffected = context.SaveChanges(); pglWorkflowId = objupdate.ProcessGuidelineWorkFlowId; } } //Document insertion if ((model.ProcessguidlineworkflowId == 0 && rowsAffected > 0) || model.ProcessguidlineworkflowId > 0) { //Remove existing document tblProcessGuidelineDocument objDocDelete; objDocDelete = context.tblProcessGuidelineDocument.Where(s => s.WorkflowId == pglWorkflowId).FirstOrDefault(); if (objDocDelete != null) { context.Entry(objDocDelete).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } //Insert new document tblProcessGuidelineDocument objDoc = new tblProcessGuidelineDocument(); objDoc.DocumentId = model.DocumentId; objDoc.WorkflowId = pglWorkflowId; context.tblProcessGuidelineDocument.Add(objDoc); context.SaveChanges(); } return(pglWorkflowId); } } catch (Exception ex) { return(-1); } }
/// <summary> /// This method used for user forgetpassword /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UserForgotPassword(ForgotPasswordModel model) { try { using (var context = new IOASDBEntities()) { var userquery = context.tblUser.SingleOrDefault(dup => dup.Email == model.Email); //if (userquery != null) //{ // string temppass = userquery.Password; // userquery.Password = Cryptography.Decrypt(temppass, "LFPassW0rd"); // if (userquery.Password != null) // { // model.password = userquery.Password; // } // //context.SaveChanges(); // //context.Dispose(); //} if (userquery != null) { string temppass = Guid.NewGuid().ToString().Substring(0, 8); userquery.Password = Cryptography.Encrypt(temppass, "LFPassW0rd"); var Disclaimer = EmailTemplate.disclaimer; using (MailMessage mm = new MailMessage(EmailTemplate.mailid, model.Email)) { mm.Subject = "IOAS Website Account Password"; string body = "Hello " + userquery.UserName + ","; body += "<br /><br />Your account password has been reset successfully. Please use the below password to log into the system"; //body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("Jobseekers.aspx", "CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>"; body += "<br />Your new password is " + temppass; body += "<br /><br />Thanks"; body += "<br /><br />________________________________________________________________________________________________________________"; body += "<br /><br />*** This is an automatically generated email, please do not reply ***"; body += "<br /><br />" + Disclaimer; mm.Body = body; mm.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient(EmailTemplate.smtpAddress, EmailTemplate.portNumber)) { smtp.Credentials = new NetworkCredential(EmailTemplate.mailid, EmailTemplate.password); //smtp.Credentials = new NetworkCredential("*****@*****.**", "ofni963"); //smtp.EnableSsl = EmailTemplate.enableSSL; smtp.Send(mm); } } context.SaveChanges(); context.Dispose(); return(true); } else { return(false); } } } catch (Exception ex) { return(true); } }
public static int PIRegistration(RegisterModel model) { try { using (var context = new IOASDBEntities()) { if (model.UserId == 0) { tblUser PIreg = new tblUser(); var chkPI = context.tblUser.FirstOrDefault(dup => dup.Email == model.Email && dup.Status == "Active"); if (chkPI != null) { return(2); } string Username = model.Createuser; PIreg.FirstName = model.Firstname; PIreg.LastName = model.Lastname; PIreg.RoleId = 7; PIreg.Dateofbirth = model.Dateofbirth; PIreg.DepartmentId = model.Department; PIreg.Gender = model.Gender; PIreg.CRTDDateTS = DateTime.Now; PIreg.UPDTDateTS = DateTime.Now; PIreg.CreatedUserId = Common.GetUserid(Username); PIreg.Email = model.Email; PIreg.Status = "Active"; PIreg.InstituteId = model.InstituteId; PIreg.UserImage = model.Image; PIreg.EMPCode = model.EMPCode; PIreg.Designation = model.Designation; context.tblUser.Add(PIreg); context.SaveChanges(); return(1); } else { var objupdatePI = context.tblUser.Where(M => M.UserId == model.UserId).FirstOrDefault(); if (objupdatePI != null) { string Username = model.Createuser; objupdatePI.FirstName = model.Firstname; objupdatePI.LastName = model.Lastname; objupdatePI.RoleId = 7; objupdatePI.Dateofbirth = model.Dateofbirth; objupdatePI.DepartmentId = model.Department; objupdatePI.Gender = model.Gender; objupdatePI.UPDTDateTS = DateTime.Now; objupdatePI.LastUpdateUserId = Common.GetUserid(Username); objupdatePI.Email = model.Email; objupdatePI.Status = "Active"; objupdatePI.InstituteId = model.InstituteId; if (model.Image != null) { objupdatePI.UserImage = model.Image; } objupdatePI.EMPCode = model.EMPCode; objupdatePI.Designation = model.Designation; context.SaveChanges(); } return(3); } } } catch (Exception ex) { return(-1); } }
/// <summary> public static int UserRegistration(RegisterModel model) { try { using (var context = new IOASDBEntities()) { using (var transaction = context.Database.BeginTransaction()) { tblUserRole objuserrole = new tblUserRole(); if (model.UserId == 0) { try { tblUser reg = new tblUser(); var chkuser = context.tblUser.FirstOrDefault(dup => dup.UserName == model.Username && dup.Status == "Active"); if (chkuser != null) { return(2); } reg.FirstName = model.Firstname; reg.LastName = model.Lastname; reg.RoleId = model.RoleId; reg.UserName = model.Username; reg.Password = Cryptography.Encrypt(model.Password, "LFPassW0rd"); reg.Dateofbirth = model.Dateofbirth; reg.DepartmentId = model.Department; reg.Gender = model.Gender; reg.CRTDDateTS = DateTime.Now; reg.UPDTDateTS = DateTime.Now; string Username = model.Createuser; reg.CreatedUserId = Common.GetUserid(Username); reg.Email = model.Username; reg.Status = "Active"; reg.UserImage = model.Image; context.tblUser.Add(reg); context.SaveChanges(); if (model.SelectedRoles != null) { var userid = (from U in context.tblUser where (U.UserName == model.Username) select U.UserId).FirstOrDefault(); model.UserId = userid; for (int i = 0; i < model.SelectedRoles.Length; i++) { objuserrole.UserId = model.UserId; objuserrole.RoleId = model.SelectedRoles[i]; objuserrole.Delegated_f = false; context.tblUserRole.Add(objuserrole); context.SaveChanges(); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); return(-1); } return(1); } else { var objupdateuser = context.tblUser.Where(U => U.UserId == model.UserId).FirstOrDefault(); if (objupdateuser != null) { try { objupdateuser.UserId = model.UserId; objupdateuser.FirstName = model.Firstname; objupdateuser.LastName = model.Lastname; objupdateuser.RoleId = model.RoleId; //bjupdateuser.UserName = model.Username; //reg.Password = Cryptography.Encrypt(model.Password, "LFPassW0rd"); objupdateuser.Dateofbirth = model.Dateofbirth; objupdateuser.DepartmentId = model.Department; objupdateuser.Gender = model.Gender; objupdateuser.UPDTDateTS = DateTime.Now; string Username = model.Createuser; objupdateuser.LastUpdateUserId = Common.GetUserid(Username); //objupdateuser.Email = model.Username; if (model.Image != null) { objupdateuser.UserImage = model.Image; } context.SaveChanges(); var username = (from U in context.tblUser where (U.UserId == model.UserId) select U.UserName).FirstOrDefault(); model.Username = username; var query = (from R in context.tblUserRole where (R.UserId == model.UserId) select R).ToList(); if (query.Count > 0) { context.tblUserRole.RemoveRange(query); context.SaveChanges(); } if (model.SelectedRoles != null) { for (int i = 0; i < model.SelectedRoles.Length; i++) { objuserrole.UserId = model.UserId; objuserrole.RoleId = model.SelectedRoles[i]; objuserrole.Delegated_f = false; context.tblUserRole.Add(objuserrole); context.SaveChanges(); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); return(-1); } } return(3); } } } } catch (Exception ex) { return(-1); } }