public bool UpdateUser(tbl_Users row) { try { using (var db = new SoneriCISEntities()) { tbl_Users u = new DAL.tbl_Users(); u = db.tbl_Users.Where(a => a.ID == row.ID).FirstOrDefault(); u.IsActive = row.IsActive; u.RoleTitle = row.RoleTitle; u.UserLogin = row.UserLogin; u.UserName = row.UserName; u.ExpiryDate = row.ExpiryDate; u.EmpCode = row.EmpCode; if (row.UserPassword == "") { u.UserPassword = u.UserPassword; } else { u.UserPassword = row.UserPassword; } u.IsActive = row.IsActive; u.AuthorizationStatus = row.AuthorizationStatus; u.AuthorizationComments = row.AuthorizationComments; db.SaveChanges(); } return(true); } catch (Exception ex) { return(false); } }
public ActionResult applyjob(Int32 id) { tbl_Jobs job = _dataContext.tbl_Jobs.Where(s => s.Pk_JobId == id).SingleOrDefault(); if (job != null) { tbl_JobEmployees employeedata = new tbl_JobEmployees(); employeedata.Fk_JobId = id; employeedata.fromUserId = clsSession.UserID; employeedata.fromUserName = clsSession.UserName; employeedata.toUserId = job.ClientUserId; employeedata.EmplyeeFeePaymentStatus = "employee requested"; employeedata.IsActive = true; employeedata.CreatedDate = DateTime.Now; _dataContext.tbl_JobEmployees.Add(employeedata); _dataContext.SaveChanges(); //Sent Email to employee to introduce about job detail...!!! //Get send user details...!!! tbl_Users touserdetail = _dataContext.tbl_Users.Where(s => s.Pk_UserId == job.ClientUserId).FirstOrDefault(); //Get Job Detail...!!! MailMessage message = new MailMessage( "*****@*****.**", // From field touserdetail.EmailId, // Recipient field "Job Request Sent by Employee", // Subject of the email message PopulateBody(clsSession.UserName, job.JobTitle, job.JobCategory, job.JobLocation, "$" + job.Amount.ToString(), job.JobDescription, false, "", false, false) // Email message body ); _sendemail.SendEmail(message); } return(RedirectToAction("jobrequested")); }
public ActionResult Login(tbl_Users log) { try { var result = db.tbl_Users.FirstOrDefault(c => c.Email == log.Email && c.Password == log.Password); if (result != null) { FormsAuthentication.SetAuthCookie(log.Email, false); Session["User"] = result; if (result.Status == 1) { return(RedirectToAction("Index", "Dashboard", new { area = "Admin" })); } else if (result.Status == 2) { return(RedirectToAction("UserProfile", "User", new { area = "User" })); } } else { ViewBag.alert = "block"; ViewBag.Error = "Invalid Credentials"; ModelState.AddModelError("", "Invalid Credentials"); return(View()); } } catch (Exception ex) { ex.ToString(); ModelState.AddModelError("unhandled", "Oops, something is wrong, have you tried checking your connection?"); } return(View()); }
public ActionResult invitejob(Guid userid) { Int32 jobid = Convert.ToInt32(TempData.Peek("JobID")); tbl_JobEmployees jobemp = new tbl_JobEmployees(); jobemp.Fk_JobId = jobid; jobemp.fromUserId = clsSession.UserID; jobemp.fromUserName = clsSession.UserName; jobemp.toUserId = userid; jobemp.EmplyeeFeePaymentStatus = "invitation sent"; jobemp.CreatedDate = DateTime.Now; jobemp.IsActive = true; _dataContext.tbl_JobEmployees.Add(jobemp); _dataContext.SaveChanges(); //Sent Email to employee to introduce about job detail...!!! //Get send user details...!!! tbl_Users touserdetail = _dataContext.tbl_Users.Where(s => s.Pk_UserId == userid).FirstOrDefault(); //Get Job Detail...!!! tbl_Jobs job = _dataContext.tbl_Jobs.Where(s => s.Pk_JobId == jobid).FirstOrDefault(); MailMessage message = new MailMessage( "*****@*****.**", // From field touserdetail.EmailId, // Recipient field "Job Request Sent by Client", // Subject of the email message PopulateBody(clsSession.UserName, job.JobTitle, job.JobCategory, job.JobLocation, "$" + job.Amount.ToString(), job.JobDescription) // Email message body ); _sendemail.SendEmail(message); return(PartialView("_invitationsentsuccess")); }
public long CreateUser(UserCreateViewModel userModel) { try { var tbl_Users = new tbl_Users(); tbl_Users.GroupID = userModel.GroupID; tbl_Users.UserFullName = userModel.UserFullName; tbl_Users.UserEmail = userModel.UserEmail; tbl_Users.UserPass = userModel.UserPass; tbl_Users.UserPhone = userModel.UserPhone; tbl_Users.UserCreateDate = DateTime.Now; tbl_Users.UserDOB = userModel.UserDOB; tbl_Users.UserExtention = userModel.UserExtention; tbl_Users.UserName = userModel.UserName; tbl_Users.UserJoinDate = userModel.UserJoinDate; tbl_Users.UserStatus = userModel.UserStatus; tbl_Users.UserComputer = userModel.UserComputer; tbl_Users.UserAddress = userModel.UserAddress; db.tbl_Users.Add(tbl_Users); var result = db.SaveChanges(); return(result); } catch (Exception ex) { Console.WriteLine(ex.Message); return(-1); } }
public ActionResult Index(order order) { try { string phone = order.phone; tbl_Users user = dbe.tbl_Users.Where(item => item.phone == phone).FirstOrDefault(); if (user == null) { tbl_Users newUser = new tbl_Users(); newUser.firstName = order.firstName; newUser.lastName = order.lastName; newUser.phone = order.phone; newUser.userEmail = order.userEmail; dbe.tbl_Users.Add(newUser); dbe.SaveChanges(); user = dbe.tbl_Users.Where(item => item.phone == phone).FirstOrDefault(); } tbl_orders newOrder = new tbl_orders(); newOrder.countPZ = Convert.ToInt32(order.countPZ); newOrder.deliveredDate = Convert.ToDateTime(order.deliveredDate); newOrder.userId = user.userId; dbe.tbl_orders.Add(newOrder); dbe.SaveChanges(); } catch (Exception e) { throw new Exception(e.ToString()); } ViewBag.Message = "Thank You For Your Order!"; return(View()); }
public ActionResult Register(HttpPostedFileBase imagefile, tbl_Users data1) { String filename = Path.GetFileName(imagefile.FileName); String filename1 = DateTime.Now.ToString("yymmssfff") + filename; string extension = Path.GetExtension(imagefile.FileName); String path = Path.Combine(Server.MapPath("/User_Image/"), filename1); data1.Profile = "/User_Image/" + filename1; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (imagefile.ContentLength <= 10000000) { imagefile.SaveAs(path); HttpClient hc = new HttpClient(); hc.BaseAddress = new Uri("https://localhost:44393/api/User/"); var registerdata = hc.PostAsJsonAsync <tbl_Users>("Register", data1); registerdata.Wait(); var savedata = registerdata.Result; if (savedata.IsSuccessStatusCode) { ModelState.Clear(); return(RedirectToAction("Login")); } } } ModelState.Clear(); return(View("Register")); }
public ActionResult Login(String email, String password) { tbl_Users obj = null; HttpClient hc = new HttpClient(); hc.BaseAddress = new Uri("https://localhost:44393/"); var logindata = hc.GetAsync("api/User/UserLogin/" + email + "/" + password); logindata.Wait(); var savedata = logindata.Result; if (savedata.IsSuccessStatusCode) { FormsAuthentication.SetAuthCookie(email, false); var displaydata = savedata.Content.ReadAsAsync <tbl_Users>(); displaydata.Wait(); obj = displaydata.Result; Session["useremail"] = obj.Email; Session["userimg"] = obj.Profile; return(RedirectToAction("Dashboard")); } else { ModelState.Clear(); return(RedirectToAction("Login")); } }
/// <summary> /// Update Member details /// </summary> /// <param name="users"></param> /// <returns></returns> public int UpdateMemberDetails(Users users) { tbl_Users tbl_users = new tbl_Users(); using (IUnitOfWorks unitOfWorks = new UnitOfWorks()) try { // tbl_Users updateMember = tbl_Users.Single(User => User.userId == userId); tbl_users.DOB = users.DOB; tbl_users.EmailId = users.EmailId; tbl_users.FirstName = users.FirstName; tbl_users.LastName = users.LastName; tbl_users.MobileNo = users.MobileNo; tbl_users.Password = users.Password; tbl_users.RoleId = users.RoleId; tbl_users.UserId = users.UserId; unitOfWorks.UserRepository.Update(tbl_users); unitOfWorks.Save(); return(1); } catch (Exception ex) { return(0); } }
public ActionResult UpdateProfile(tbl_Users request, int?RequestId = null) { //var flag = new UserDataAccess().UpdateUser(request); var getUserDetails = UserMethods.GetUserDetailsByID(request.ID); var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault()); request.UserPassword = getUserDetails.UserPassword; request.AuthorizationStatus = getUserDetails.AuthorizationStatus; request.AuthorizationComments = getUserDetails.AuthorizationComments; var existingJson = getUserDetails == null ? null : CustomHelper.GetJson(getUserDetails); var updatedJson = CustomHelper.GetJson(request); var row = new tbl_System_Requests { ID = RequestId ?? 0, AuthorizationStatus = "P", CreatorID = StateHelper.UserId, IsActive = true, ExistingData = existingJson, UpdatedData = updatedJson, RequestType = Constants.RequestTypes.UserModification, AuthorizerID = getSystemRequest?.AuthorizerID ?? 0, AuthorizationComments = getSystemRequest?.AuthorizationComments ?? string.Empty }; var flag = (!RequestId.HasValue || RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row) : new SystemRequestDataAccess().UpdateSystemRequest(row); return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? CustomMessages.UserProfileUpdateSuccessfully : CustomMessages.GenericErrorMessage }, JsonRequestBehavior.AllowGet)); }
public ActionResult View(Guid id) { tbl_Roles role = _dataContext.tbl_Roles.Where(x => x.RoleName == "Employee").FirstOrDefault(); tbl_Users employee = _dataContext.tbl_Users.Where(x => x.Fk_RoleId == role.Pk_RoleId && x.Pk_UserId == id).FirstOrDefault(); return(View("~/Areas/user/Views/EmployeeList/ViewEmployee.cshtml", employee)); }
public ActionResult approvejob(Int32 id, Guid fromId) { tbl_JobEmployees jobstatus = _dataContext.tbl_JobEmployees.Where(s => s.Fk_JobId == id && s.fromUserId == fromId).FirstOrDefault(); jobstatus.EmplyeeFeePaymentStatus = "Approved"; _dataContext.SaveChanges(); //For Change Job Status...!!! tbl_Jobs job = _dataContext.tbl_Jobs.Where(s => s.Pk_JobId == id).FirstOrDefault(); List <tbl_JobEmployees> jobemployeedata = _dataContext.tbl_JobEmployees.Where(s => s.Fk_JobId == id && s.EmplyeeFeePaymentStatus == "Approved").ToList(); if (jobemployeedata.Count >= job.NoOfEmployeeNeeded) { job.JobStatus = "Approved"; _dataContext.SaveChanges(); } //Sent Email to employee to introduce about job detail...!!! //Get send user details...!!! tbl_Users touserdetail = _dataContext.tbl_Users.Where(s => s.Pk_UserId == jobstatus.fromUserId).FirstOrDefault(); string userid = EncrytDecrypt.passwordEncrypt(clsSession.UserID.ToString(), true); string jobid = EncrytDecrypt.passwordEncrypt(job.Pk_JobId.ToString(), true); string paymenturl = "http://hardyhat.com/user/payment/checkout?userid=" + clsSession.UserID.ToString() + "&jobid=" + job.Pk_JobId.ToString(); //Get Job Detail...!!! MailMessage message = new MailMessage( "*****@*****.**", // From field touserdetail.EmailId, // Recipient field "Job Approved by Client", // Subject of the email message PopulateBody(clsSession.UserName, job.JobTitle, job.JobCategory, job.JobLocation, "$" + job.Amount.ToString(), job.JobDescription, true, paymenturl, false, false) // Email message body ); return(RedirectToAction("clientjobproposal")); }
public ActionResult View(Guid?id) { //check view client role tbl_Roles role = _dataContext.tbl_Roles.Where(x => x.RoleName == "Client").FirstOrDefault(); tbl_Users client = _dataContext.tbl_Users.Where(x => x.Fk_RoleId == role.Pk_RoleId && x.Pk_UserId == id).FirstOrDefault(); return(View("~/Areas/user/Views/ClientList/ViewClient.cshtml", client)); }
public ActionResult DeleteConfirmed(string id) { tbl_Users tbl_Users = db.tbl_Users.Find(id); db.tbl_Users.Remove(tbl_Users); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Display(tbl_Users u) { u.SlNo = u.SlNo != null ? u.SlNo : 0; u.UserName = u.UserName != null ? u.UserName : ""; u.EmailId = u.EmailId != null ? u.EmailId : ""; u.Password = u.Password != null ? u.Password : ""; u.ConfirmPassword = u.ConfirmPassword != null ? u.ConfirmPassword : ""; return(PartialView(u)); }
public ActionResult Register(tbl_Users tUsers, HttpPostedFileBase Pic) { tUsers.Access = "Writer"; tUsers.Enable = false; if (ModelState.IsValid) { if (Pic != null) { if (Pic.ContentType == "image/jpeg") { if (Pic.ContentLength <= 81920) { Random rnd = new Random(); string rndName = rnd.Next(1, 100000).ToString() + ".jpg"; string path = Path.Combine(Server.MapPath("~/Content/Images/Users/")); Pic.SaveAs(path + rndName); tUsers.Image = rndName; } else { ViewBag.Style = "color:red"; ViewBag.Message = "حجم تصویر نباید بیشتر از 80 کیلو بایت باشد"; return(View()); } } else { ViewBag.Style = "color:red"; ViewBag.Message = "فرمت تصویر باید jpg باشد"; return(View()); } } else { tUsers.Image = "Default.jpg"; } db.tbl_Users.Add(tUsers); if (Convert.ToBoolean(db.SaveChanges())) { ViewBag.Style = "color:green"; ViewBag.Message = "عضویت با موفقیت انجام شد"; return(View()); } else { ViewBag.Style = "color:red"; ViewBag.Message = "متاسفانه عضویت با موفقیت انجام نشد"; return(View()); } } else { ViewBag.Style = "color:red"; ViewBag.Message = "تمامی فیلدها را به صورت صحیح پر نمایید"; } return(View()); }
// Create a new user. public tbl_Users POST([FromBody] tbl_Users users) { using (ClaimyWebServies_dbEntities2 entity = new ClaimyWebServies_dbEntities2()) { entity.Configuration.ProxyCreationEnabled = false; entity.tbl_Users.Add(users); entity.SaveChanges(); return(users); } }
public ActionResult Register(tbl_Users request) { request.UserPassword = "******"; request.UserPassword = EncryptionHelper.HashString(request.UserPassword); request.IsActive = true; request.AuthorizationStatus = "P"; var flag = request.ID > 0 ? new UserDataAccess().UpdateUser(request) : new UserDataAccess().Register(request); return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? CustomMessages.Success : CustomMessages.GenericErrorMessage, Response = (flag == true) ? Url.Action("Index", "Login") : null }, JsonRequestBehavior.AllowGet)); }
protected MasterData(tbl_Users user, string formName = "", string masterKey = "", string formType = "") { BranchCode = user.BranchCode; CompanyCode = user.CompanyCode; UserId = user.UserID; FormType = formType; MasterKey = masterKey; FormName = formName; User = user; }
public tbl_Users GetUserOBFromLoginViewModel(LoginViewModel loginView) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <LoginViewModel, tbl_Users>(); }); IMapper iMapper = config.CreateMapper(); UserOB = iMapper.Map <LoginViewModel, tbl_Users>(loginView); return(UserOB); }
public ActionResult Edit([Bind(Include = "userName,password,name,shortName,admin,active,id")] tbl_Users tbl_Users) { if (ModelState.IsValid) { db.Entry(tbl_Users).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Users)); }
public LoginViewModel GetLoginViewModelFromUserOB(tbl_Users userOB) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <tbl_Users, LoginViewModel>(); }); IMapper iMapper = config.CreateMapper(); LoginViewModel = iMapper.Map <tbl_Users, LoginViewModel>(userOB); return(LoginViewModel); }
public ActionResult Form_Save(tbl_Users u) { if (ModelState.IsValid) { db.tbl_Users.Add(u); db.SaveChanges(); return(RedirectToAction("Display", u)); } return(PartialView()); }
public ActionResult approve(Int32 id) { tbl_JobEmployees jobstatus = _dataContext.tbl_JobEmployees.Where(s => s.Fk_JobId == id && s.toUserId == clsSession.UserID).FirstOrDefault(); jobstatus.EmplyeeFeePaymentStatus = "Approved"; _dataContext.SaveChanges(); //For Change Job Status...!!! tbl_Jobs job = _dataContext.tbl_Jobs.Where(s => s.Pk_JobId == id).FirstOrDefault(); //Sent Email to employee to introduce about job detail...!!! //Get send user details...!!! tbl_Users touserdetail = _dataContext.tbl_Users.Where(s => s.Pk_UserId == clsSession.UserID).FirstOrDefault(); //Get Job Detail...!!! string userid = EncrytDecrypt.passwordEncrypt(clsSession.UserID.ToString(), true); string jobid = EncrytDecrypt.passwordEncrypt(id.ToString(), true); string paymenturl = "http://hardyhat.com/user/payment/checkout?userid=" + clsSession.UserID.ToString() + "&jobid=" + id.ToString(); MailMessage message = new MailMessage( "*****@*****.**", // From field touserdetail.EmailId, // Recipient field "Pending For Payment Approval", // Subject of the email message PopulateBody(clsSession.UserName, job.JobTitle, job.JobCategory, job.JobLocation, "$" + job.Amount.ToString(), job.JobDescription, false, paymenturl, true, false) // Email message body ); _sendemail.SendEmail(message); List <tbl_JobEmployees> jobemployeedata = _dataContext.tbl_JobEmployees.Where(s => s.Fk_JobId == id && s.EmplyeeFeePaymentStatus == "Approved").ToList(); bool updateFlag = false; if (jobemployeedata.Count >= job.NoOfEmployeeNeeded) { updateFlag = true; //Sent Email to employee to introduce about job detail...!!! //Get send user details...!!! tbl_Users touserdetailClient = _dataContext.tbl_Users.Where(s => s.Pk_UserId == jobstatus.fromUserId).FirstOrDefault(); //Get Job Detail...!!! string touserid = EncrytDecrypt.passwordEncrypt(touserdetailClient.Pk_UserId.ToString(), true); string tojobid = EncrytDecrypt.passwordEncrypt(job.Pk_JobId.ToString(), true); string paymenturlClient = "http://hardyhat.com/user/payment/checkout?userid=" + touserdetailClient.Pk_UserId.ToString() + "&jobid=" + job.Pk_JobId.ToString(); MailMessage messageClient = new MailMessage( "*****@*****.**", // From field touserdetail.EmailId, // Recipient field "Pending For Payment Approval", // Subject of the email message PopulateBody(clsSession.UserName, job.JobTitle, job.JobCategory, job.JobLocation, "$" + job.Amount.ToString(), job.JobDescription, false, paymenturlClient, false, true) // Email message body ); _sendemail.SendEmail(messageClient); } if (updateFlag) { tbl_Jobs jobupdate = _dataContext.tbl_Jobs.Find(id); if (TryValidateModel(jobupdate)) { jobupdate.JobStatus = "Approved"; _dataContext.SaveChanges(); } } return(RedirectToAction("jobproposals")); }
public void CreateTest() { tbl_Users User = new tbl_Users(); Mock<IUserRepository> MockIUserRepository = new Mock<IUserRepository>(); MockIUserRepository.Setup(X => X.CreateUser(It.IsAny<tbl_Users>())).Returns(true); var Result = var Result = new UserController(ObjUser.Object).Create(User);; Assert.That(Result, //is a view result with expected view model); Assert.That(ObjUser.Verify(), Is.True); }
public IHttpActionResult UserLogin(String email, string password) { tbl_Users obj = dbobj.tbl_Users.Where(x => x.Email == email && x.Password == password).FirstOrDefault <tbl_Users>(); if (obj == null) { return(NotFound()); } return(Ok(obj)); }
public ActionResult Create([Bind(Include = "userName,password,name,shortName,admin,active,id")] tbl_Users tbl_Users) { if (ModelState.IsValid) { db.tbl_Users.Add(tbl_Users); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Users)); }
public static tbl_Users GetActiveUser() { if (IsAuthenticated()) { tbl_Users User = memberService.GetById(GetActiveUserId); UserServices userViewModel = new UserServices(); userViewModel.activeUser = User; return(userViewModel.activeUser); } return(null); }
// GET: Users/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_Users tbl_Users = db.tbl_Users.Find(id); if (tbl_Users == null) { return(HttpNotFound()); } return(View(tbl_Users)); }
public LoginViewModel GetLoggedInUser(string UserName, string Password) { LoginViewModel loginView = null; try { tbl_Users userOB = _dbContext.tbl_Users.Where(u => u.UserName.Equals(UserName) && u.Password.Equals(Password)).FirstOrDefault(); loginView = _userMapper.GetLoginViewModelFromUserOB(userOB); return(loginView); } catch (Exception ex) { return(null); } }