public List <UserMasterModel> GetAllUserDetails() { try { List <UserMasterModel> modellist = new List <UserMasterModel>(); var datalist = tRSEntities2.UserMasters.Where(x => x.IsActive == true).ToList(); if (datalist != null) { foreach (var item in datalist) { UserMasterModel model = new UserMasterModel(); model.Id = item.Id; model.FirstName = item.FirstName; model.LastName = item.LastName; model.Address = item.Address; model.Gender = item.Gender; model.EmailId = item.EmailId; model.Mobile = item.Mobile; model.UserName = item.UserName; model.Password = item.Password; model.DOM = item.DOM; model.DOC = item.DOC; model.UserType = item.UserType; model.IsActive = item.IsActive; modellist.Add(model); } } return(modellist); } catch (Exception e) { throw e; } }
protected void btnSave_Click(object sender, EventArgs e) { if (IsValidInput()) { int userNo = 0; int.TryParse(Session["userNo"].ToString(), out userNo); UserMasterModel user = new UserMasterModel() { UserNo = userNo, userName = txtUserId.Text, UserProfileName = txtUserProfileName.Text, Password = txtpwd.Text, SecQue = Convert.ToByte(ddlSecQue.SelectedValue), SecAns = txtsecAns.Text }; UserMasterBusiness userBusiness = new UserMasterBusiness(); Label lbl = (Label)this.FindControl("pageAlert"); if (userBusiness.Add(user)) { Response.Write("Success"); } else { Response.Write("Register User Failed"); lbl.CssClass = "alert alert-danger"; } } }
public bool UpdateUserDetails(UserMasterModel modal) { try { var UserDetails = tRSEntities2.UserMasters.Where(x => x.Id == modal.Id).FirstOrDefault(); if (UserDetails != null) { UserDetails.Id = modal.Id; UserDetails.FirstName = modal.FirstName; UserDetails.LastName = modal.LastName; UserDetails.Address = modal.Address; UserDetails.Gender = modal.Gender; UserDetails.EmailId = modal.EmailId; UserDetails.Mobile = modal.Mobile; UserDetails.DOM = UserDetails.DOM; UserDetails.DOC = DateTime.Now; UserDetails.IsActive = true; tRSEntities2.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
public async Task <IActionResult> Create(UserMasterModel viewModel, bool continueEditing) { if (ModelState.IsValid) { var userModel = new UserMaster { UserGuid = Guid.NewGuid(), FirstName = viewModel.FirstName, LastName = viewModel.LastName, EmailId = viewModel.Email, ContactNumber = viewModel.ContactNumber, Address = viewModel.Address, DesignationId = viewModel.DesignationId, UnderDesId = viewModel.UnderDesId, UserName = viewModel.UserName, Password = viewModel.Password, DateCreated = DateTime.UtcNow, }; await _userMasterService.InsertAsync(userModel); if (continueEditing) { return(RedirectToAction(nameof(Edit), new { id = userModel.Id })); } return(RedirectToAction(nameof(List))); } return(View(viewModel)); }
public dynamic PostLoginAuthentication(UserMasterModel objtblusermaster) { using (LystenEntities db = new LystenEntities()) { var paswrdenc = SecutiryServices.EncodePasswordToBase64(objtblusermaster.Password); var result = (from um in db.User_Master where um.Email.ToUpper() == objtblusermaster.Email.ToUpper() && um.Password == paswrdenc && um.IsActive == true select um ).ToList(); if (result.Count > 0) { int id = result.Select(y => y.Id).FirstOrDefault(); var chkToken = db.AppAccessTokens.Where(x => x.UserId == id).FirstOrDefault(); if (chkToken != null) { db.Entry(chkToken).State = EntityState.Deleted; db.SaveChanges(); } objresult.Code = 200; objresult.Msg = "Success"; objresult.Data = result; } else { objresult.Code = 0; objresult.Msg = "Something Went Wrong."; objresult.Data = result; } return(objresult); } }
public async Task <IActionResult> Edit(int id) { var userInfo = await _userMasterService.GetUserByIdAsync(id); if (userInfo == null) { return(RedirectToAction("List")); } var viewModel = new UserMasterModel { Id = userInfo.Id, FirstName = userInfo.FirstName, LastName = userInfo.LastName, Email = userInfo.EmailId, ContactNumber = userInfo.ContactNumber, Address = userInfo.Address, DesignationId = userInfo.DesignationId, UnderDesId = userInfo.UnderDesId, UserName = userInfo.UserName, Password = userInfo.Password, ContinueEditing = IsContinueEditingAllowed() }; viewModel.AvailableDesignations = await BindDesignationsList(); viewModel.AvailableUnderDesIds = await BindSMandTLList(); return(View(viewModel)); }
public async Task <IActionResult> Edit(UserMasterModel model, bool continueEditing) { var userInfo = await _userMasterService.GetUserByIdAsync(model.Id); if (userInfo == null) { return(RedirectToAction("List")); } userInfo.FirstName = model.FirstName; userInfo.LastName = model.LastName; userInfo.EmailId = model.Email; userInfo.ContactNumber = model.ContactNumber; userInfo.Address = model.Address; userInfo.DesignationId = model.DesignationId; userInfo.UnderDesId = model.UnderDesId; userInfo.DateCreated = DateTime.UtcNow; await _userMasterService.UpdateAsync(userInfo); AllowContinueEditing(continueEditing); if (continueEditing) { return(RedirectToAction(nameof(UserMasterController.Edit), new { id = userInfo.Id })); } return(RedirectToAction(nameof(UserMasterController.List))); }
public ActionResult ResizeProfileImage(UserMasterModel QModel) { var postedFile = Request.Files["ProfilePicture"]; if (postedFile != null) { Image img = Image.FromStream(postedFile.InputStream, true, true); img = ResizeImage(img, 600, 600, true, false); using (MemoryStream m = new MemoryStream()) { img.Save(m, ImageFormat.Png); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String string base64String = Convert.ToBase64String(imageBytes); base64String = "data:image/png; base64," + base64String; return(Json(new { success = true, base64 = base64String, height = img.Height, width = img.Width })); } } else { return(Json(new { success = false })); } }
public UserMasterModel GetUserMasterDetail(int id) { try { var data = tRSEntities2.UserMasters.Where(x => x.Id == id && x.IsActive == true).FirstOrDefault(); UserMasterModel model = new UserMasterModel(); if (data != null) { model.Id = data.Id; model.FirstName = data.FirstName; model.LastName = data.LastName; model.Address = data.Address; model.Gender = data.Gender; model.UserName = data.UserName; model.EmailId = data.EmailId; model.UserType = data.UserType; model.Mobile = data.Mobile; model.DOC = data.DOC; model.DOM = DateTime.Now; model.IsActive = true; } return(model); } catch (Exception e) { throw e; } }
public UserMasterModel GetUserMasterLogin(string UserName, string Password) { try { byte[] Originalbytes = Encoding.Unicode.GetBytes(Password); byte[] Encodedbytes = md5.ComputeHash(Originalbytes); Password = BitConverter.ToString(Encodedbytes).Replace("-", "").ToLower(); var data = tRSEntities2.UserMasters.Where(x => x.UserName == UserName && x.Password == Password).FirstOrDefault(); UserMasterModel model = new UserMasterModel(); if (data != null) { model.UserName = data.UserName; model.Password = data.Password; model.UserType = data.UserType; } else { model.UserName = "******"; model.Password = ""; model.UserType = ""; } return(model); } catch (Exception e) { throw e; } }
public ActionResult DeleteConfirmed(int id) { UserMasterModel userMasterModel = db.UserMasters.Find(id); db.UserMasters.Remove(userMasterModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public HttpResponseMessage Register([FromBody] UserMasterModel NewUser) { try { if (ModelState.IsValid) { if (context.UserMasters.FirstOrDefault(u => u.SSN == NewUser.SSN) != null) { UserMasterErrorModel ErrorSSN = new UserMasterErrorModel(); ErrorSSN.User = NewUser; ErrorSSN.ErrorMessage = "SSN must be unique"; return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorSSN)); } var found = context.UserMasters.FirstOrDefault(u => u.UserName == NewUser.UserName); if (found == null) { var user = new UserMaster(); user.UserName = NewUser.UserName; user.UserEmailID = NewUser.UserEmailID; user.UserRoles = "user"; user.UserPassword = NewUser.UserPassword; user.PhoneNumber = NewUser.PhoneNumber; user.city = NewUser.city; user.SSN = NewUser.SSN; context.UserMasters.Add(user); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "registeration was sucessful")); } UserMasterErrorModel error = new UserMasterErrorModel(); error.User = NewUser; error.ErrorMessage = "User name must be unique"; var message = Request.CreateResponse(HttpStatusCode.BadRequest, error); message.Headers.Location = new Uri(Request.RequestUri + "/"); return(message); } else { var message = Request.CreateResponse(HttpStatusCode.BadRequest, NewUser); message.Headers.Location = new Uri(Request.RequestUri + "/"); return(message); } } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, e.InnerException)); } }
public async Task <IActionResult> Create() { var model = new UserMasterModel(); model.AvailableDesignations = await BindDesignationsList(); model.AvailableUnderDesIds = await BindSMandTLList(); return(View(model)); }
public bool Add(UserMasterModel newUser) { newUser.UserType = "Demo"; newUser.UserStatus = UserStatusType.Active; newUser.Password = Security.PasswordManager.EncryptPassword(newUser.Password); newUser.SecAns = Security.PasswordManager.EncryptPassword(newUser.SecAns); UserMasterData userData = new UserMasterData(newUser); return(userData.Save()); }
public ActionResult Edit([Bind(Include = "Id,FirstName,MiddleName,LastName,Designation_Id,JoiningDate,IsPermanent,IsActive,Shift")] UserMasterModel userMasterModel) { if (ModelState.IsValid) { db.Entry(userMasterModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Designation_Id = new SelectList(db.DesignationMasters, "Id", "Designation", userMasterModel.Designation_Id); return(View(userMasterModel)); }
public int AddUser(UserMasterModel model) { try { return(_user.InsertUser(model.EmailId, model.FullName, model.MobileNo)); } catch (Exception ex) { return(0); } }
public int UpdateUser(UserMasterModel model) { try { _user.UpdatedUser(model.Id, model.EmailId, model.FullName, model.MobileNo); return(model.Id); } catch (Exception ex) { return(0); } }
// GET: User/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserMasterModel userMasterModel = db.UserMasters.Find(id); if (userMasterModel == null) { return(HttpNotFound()); } return(View(userMasterModel)); }
// POST api/<controller> public async Task <IHttpActionResult> Login([FromBody] UserMasterModel UM) { ResultClass result = new ResultClass(); try { result = await ApiCommon.PostLoginAuthenticationAsync(UM); return(Ok(result)); } catch (Exception ex) { return(Ok(ApiEx.FireException(result, ex))); } }
public bool AuthenticateUser(string userName, string password) { UserMasterModel objUserMaster = _context.TblUserMaster.Where(a => a.UserName == userName && a.Password == password).FirstOrDefault(); if (objUserMaster != null) { SessionExtensions.SetString(_httpContextAccessor.HttpContext.Session, Constants.SessionUserSessions, JsonConvert.SerializeObject(objUserMaster)); SessionExtensions.SetString(_httpContextAccessor.HttpContext.Session, Constants.SessionUserId, Convert.ToString(objUserMaster.Id)); return(true); } else { return(false); } }
// GET: User/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserMasterModel userMasterModel = db.UserMasters.Find(id); if (userMasterModel == null) { return(HttpNotFound()); } ViewBag.Designation_Id = new SelectList(db.DesignationMasters, "Id", "Designation", userMasterModel.Designation_Id); return(View(userMasterModel)); }
private async Task <List <SelectListItem> > BindSMandTLList() { var model = new UserMasterModel(); model.AvailableUnderDesIds.Add(new SelectListItem { Value = "0", Text = "Select Under This SM/TL" }); var usersList = await _userMasterService.GetSMandTLList(); foreach (var item in usersList) { model.AvailableUnderDesIds.Add(new SelectListItem { Value = item.Id.ToString(), Text = item.FirstName + " " + item.LastName }); } return(model.AvailableUnderDesIds); }
private async Task <List <SelectListItem> > BindDesignationsList() { var model = new UserMasterModel(); model.AvailableDesignations.Add(new SelectListItem { Value = "0", Text = "Select Designation" }); var designationsList = await _designationMasterService.GetAllDesignationsListAsync(); foreach (var item in designationsList) { model.AvailableDesignations.Add(new SelectListItem { Value = item.Id.ToString(), Text = item.Designation }); } return(model.AvailableDesignations); }
private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha, string Domain, int Event, int ReferralId) { Domain = Domain.Trim().ToLower(); SearchTitle = SearchTitle.Trim().ToLower(); Alpha = Alpha.Trim().ToLower(); int CustomerId = Convert.ToInt32(Session["CustomerId"]); List <UserMasterModel> userlist = new List <UserMasterModel>(); var regusers = RegisteredUserService.Eventwiseuser(SearchTitle, Alpha, Domain, Event, CustomerId, ReferralId); foreach (var user in regusers) { UserMasterModel model = new UserMasterModel(); model.UserId = user.UserId; model.FirstName = user.FirstName; model.LastName = user.LastName; model.ReferredBy = user.ReferredBy; model.Email = user.Email; model.Country = user.Country; model.DomainName = user.DomainName; model.EventId = user.EventId; model.EventName = user.EventName; model.EventStartDate = user.EventStartDate; model.EventEndDate = user.EventEndDate; model.DateOfRegistration = user.DateOfRegistration; model.ReferralCount = Convert.ToInt32(user.ReferralCount); model.ConnectionCount = Convert.ToInt32(user.ConnectionCount); model.ProfileImage = user.ProfileImage; model.visitorcount = user.VisitorCount; model.CRM_CompanyName = user.CRM_CompanyName; model.CRM_JobTitle = user.CRM_JobTitle; model.CRM_RegistrationId = user.CRM_RegistrationId; model.Source = user.Source; userlist.Add(model); } ViewBag.TotalCount = RegisteredUserService.GetRegisteredUserByEventId(Event).Count(); return(userlist); }
public bool SaveUserMaster(UserMasterModel model) { try { if (model != null) { UserMaster item = new UserMaster(); item.Id = model.Id; item.FirstName = model.FirstName; item.LastName = model.LastName; item.Address = model.Address; item.Gender = model.Gender; item.EmailId = model.EmailId; item.Mobile = model.Mobile; item.UserType = model.UserType; item.UserName = model.UserName; //Encrypt Password using md5 byte[] Originalbytes = Encoding.Unicode.GetBytes(model.Password); byte[] Encodedbytes = md5.ComputeHash(Originalbytes); item.Password = BitConverter.ToString(Encodedbytes).Replace("-", "").ToLower(); // End item.DOC = DateTime.Now; item.DOM = DateTime.Now; item.IsActive = true; var data = tRSEntities2.UserMasters.Add(item); tRSEntities2.SaveChanges(); return(true); } return(true); } catch (Exception e) { throw e; } }
public ActionResult Login(FormCollection FC, string ReturnUrl) { try { UserMasterModel UM = new UserMasterModel(); UM.Email = Request.Form["Email"]; UM.Password = Request.Form["Password"]; if (Convert.ToString(Request.Form["RememberMe"]) == "on") { UM.RememberMe = true; } else { UM.RememberMe = false; } var result = cs.PostLoginAuthentication(UM); if (result.Code == 200) { if (UM.RememberMe) { Response.Cookies["UserName"].Expires = DateTime.Now.AddYears(1); Response.Cookies["Password"].Expires = DateTime.Now.AddYears(1); Response.Cookies["UserName"].Value = UM.Email; Response.Cookies["Password"].Value = UM.Password; } else { Response.Cookies["UserName"].Expires = DateTime.Now.AddYears(-1); Response.Cookies["Password"].Expires = DateTime.Now.AddYears(-1); Response.Cookies["UserName"].Value = "0"; Response.Cookies["Password"].Value = "0"; } var objuser = (result.Data[0]); objuser.SessionId = System.Web.HttpContext.Current.Session.SessionID; MS.updatesession(objuser); HttpCookie UserCookies = new HttpCookie("Userid"); UserCookies.Value = Convert.ToString(objuser.Id); UserCookies.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(UserCookies); HttpCookie SessionIDCookies = new HttpCookie("SessionID"); SessionIDCookies.Value = System.Web.HttpContext.Current.Session.SessionID; SessionIDCookies.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(SessionIDCookies); //HttpContext.Application["usr_" + objuser.Id] = HttpContext.Session.SessionID; // FormsAuthentication.SetAuthCookie(objuser.um.Username, false); FormsAuthentication.SetAuthCookie(objuser.Email, false); if (ReturnUrl != null) { ReturnUrl = ReturnUrl.Remove(0, 1); return(RedirectToRoute(ReturnUrl)); } if (objuser.RoleId == 1) { return(RedirectToRoute("dashboard")); } else { return(View()); } } else { ViewBag.Errormsg = "Invalid Email Or Password!"; return(View()); } } catch (Exception ex) { CommonServices.ErrorLogging(ex); throw ex; } }
public BaseApiResponse SaveUserDetail(UserMasterModel model) { return(_iService.SaveUserDetail(model)); }
//[HttpPost] public ActionResult GetRegisteredUserByUserId(int UserId) { try { var registeredUser = db.RegisteredUsers.Find(UserId); var eventid = registeredUser.EventId; var eventtopost = db.EventMasters.Find(eventid); var adminsetting = AdminService.GetAdminSetting(); var utmsource = adminsetting.Utm_Source; var utmmedium = adminsetting.Utm_Medium; var utmcampaign = adminsetting.Utm_Campaign; var utmcontent = UserId; var utmterm = eventid; eventtopost.Commentary = eventtopost.Commentary.Replace("\r\n", " "); var referralLink = ""; if (eventtopost.DomainName.Contains("?")) { referralLink = eventtopost.DomainName;// + "&r=" + UserId; if (!eventtopost.DomainName.Contains("utm_source")) { referralLink = referralLink + "&utm_source=" + utmsource; } if (!eventtopost.DomainName.Contains("utm_medium")) { referralLink = referralLink + "&utm_medium=" + utmmedium; } if (!eventtopost.DomainName.Contains("utm_campaign")) { referralLink = referralLink + "&utm_campaign=" + utmcampaign; } if (!eventtopost.DomainName.Contains("utm_content")) { referralLink = referralLink + "&utm_content=" + utmcontent; } if (!eventtopost.DomainName.Contains("utm_term")) { referralLink = referralLink + "&utm_term=" + utmterm; } referralLink = referralLink + "&r=" + UserId; } else { referralLink = eventtopost.DomainName + "?test=" + UserId; if (!eventtopost.DomainName.Contains("utm_source")) { referralLink = referralLink + "&utm_source=" + utmsource; } if (!eventtopost.DomainName.Contains("utm_medium")) { referralLink = referralLink + "&utm_medium=" + utmmedium; } if (!eventtopost.DomainName.Contains("utm_campaign")) { referralLink = referralLink + "&utm_campaign=" + utmcampaign; } if (!eventtopost.DomainName.Contains("utm_content")) { referralLink = referralLink + "&utm_content=" + utmcontent; } if (!eventtopost.DomainName.Contains("utm_term")) { referralLink = referralLink + "&utm_term=" + utmterm; } referralLink = referralLink + "&r=" + UserId; } referralLink = System.Web.HttpUtility.UrlEncode(referralLink); var register_userlist = new RegisteredUserModel(); var client = new RestClient("https://api-ssl.bitly.com/v3/shorten?access_token=96cc216b40bdbce6e032fcaeb2505ff997986706&longUrl=" + referralLink); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { dynamic tmp = JsonConvert.DeserializeObject(response.Content); referralLink = (string)tmp.data.url; } List <UserMasterModel> userlist = new List <UserMasterModel>(); var regusers = RegisteredUserService.Eventwiseuser("", "", "", (int)eventid, eventtopost.CustomerId, 0).ToList().Where(x => x.UserId != UserId); foreach (var user in regusers) { UserMasterModel model = new UserMasterModel(); model.UserId = user.UserId; model.FullName = user.FirstName + " " + user.LastName; model.ReferredBy = user.ReferredBy; model.Email = user.Email; model.Country = user.Country; model.DomainName = user.DomainName; model.EventId = user.EventId; model.EventName = user.EventName; model.EventStartDate = user.EventStartDate; model.EventEndDate = user.EventEndDate; model.DateOfRegistration = user.DateOfRegistration; model.ReferralCount = Convert.ToInt32(user.ReferralCount); model.ConnectionCount = Convert.ToInt32(user.ConnectionCount); model.ProfileImage = user.ProfileImage; model.visitorcount = user.VisitorCount; model.CRM_CompanyName = user.CRM_CompanyName != null ? user.CRM_CompanyName : ""; model.CRM_JobTitle = user.CRM_JobTitle != null ? user.CRM_JobTitle : ""; model.CRM_RegistrationId = user.CRM_RegistrationId; model.Source = user.Source; userlist.Add(model); } return(Json(new { RegisteredUser = userlist, success = true, ReferralLink = referralLink }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = "Could not saved Data" })); } }
public IHttpActionResult SaveUserMaster(UserMasterModel model) { var data = IUserMasterRepo.SaveUserMaster(model); return(Ok(data)); }
public IHttpActionResult UpdateUserDetails(UserMasterModel model) { var data = IUserMasterRepo.UpdateUserDetails(model); return(Ok(data)); }