public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var db = new ApplicationDb(); var login = new UserAcount { Name = model.Name, Email = model.Email, Age = model.Age, Phone = model.Phone, ApplicationUserId = user.Id }; db.UserAcounts.Add(login); db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string 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 <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Register(UserAcount account) { if (ModelState.IsValid) { using (CCV_Tables_Context db = new CCV_Tables_Context()) { bool isAlreadyRegistered = db.UserAcounts.Any(c => c.Password == account.Password) && db.UserAcounts.Any(c => c.Username == account.Username); if (!isAlreadyRegistered) { db.UserAcounts.Add(account); db.SaveChanges(); ModelState.Clear(); TempData["WelcomeUser"] = account.LastName + " " + account.FirstName + " successfully registered"; return(RedirectToAction("Login")); } else { TempData["AlreadyExist"] = "Please change your password or username"; } } ViewBag.Message = account.LastName + " " + account.FirstName + " successfully registered"; } return(View()); }
protected void Approve() { System.Text.StringBuilder strUserIds = new System.Text.StringBuilder(); foreach (GridViewRow i in grdAgent.Rows) { CheckBox c1 = (CheckBox)i.FindControl("chkSelect"); if (c1.Checked == true) { string UserId = grdAgent.DataKeys[i.RowIndex].Values[0].ToString() + ","; strUserIds.Append(UserId); } } if (strUserIds.Length > 0) { strUserIds.Remove(strUserIds.Length - 1, 1); oUserAcount = new UserAcount { Flag = 4, UserIds = strUserIds.ToString(), IsActive = true }; oPUserAcount = new PUserAcount(); ds = oPUserAcount.UserAcount(oUserAcount); lblMsg.Visible = true; lblMsg.Text = ds.Tables[0].Rows[0][0].ToString(); Bind(); } else { lblMsg.Visible = true; lblMsg.Text = "No agent is selected."; lblMsg.CssClass = "valid"; return; } }
protected void UserAuthentication() { oUserAcount = new UserAcount { Flag = 2, EMail = txtEMail.Text, Password = txtPassword.Text, }; oPUserAcount = new PUserAcount(); ds = oPUserAcount.UserAcount(oUserAcount); string s = ds.Tables[0].Rows[0][0].ToString(); string[] Param = s.Split(new string[] { "*" }, StringSplitOptions.None); if (Param.Length == 3) { Session["User_ID"] = Param[0]; Session["User_Type"] = Param[1]; Session["Login"] = Param[2]; if (Param[1] == "4") { Response.Redirect("~/Administration/AgentApprove.aspx"); } } else { lblFailureText.Visible = true; lblFailureText.Text = s; } }
public ActionResult DeleteConfirmed(int id) { UserAcount userAcount = db.UserAcounts.Find(id); db.UserAcounts.Remove(userAcount); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void UserAuthentication() { oUserAcount = new UserAcount { Flag = 2, EMail = txtEMail.Text, Password = txtPassword.Text, }; oPUserAcount = new PUserAcount(); ds = oPUserAcount.UserAcount(oUserAcount); string s = ds.Tables[0].Rows[0][0].ToString(); string[] Param = s.Split(new string[] { "*" }, StringSplitOptions.None); if (Param.Length == 3) { Session["User_ID"] = Param[0]; Session["User_Type"] = Param[1]; Session["Login"] = Param[2]; liAcount.Visible = true; tblLogin.Visible = true; divImage.Visible = true; if (Param[1] == "4") { //Admin Response.Redirect("~/Administration/UserProfile.aspx"); } else if (Param[1] == "3") { //POS Response.Redirect("~/Booking/BookingCounter.aspx"); } else { //Normal User,Agent,POS Session["Booking_Quoto"] if (Param[1] == "2") { Session["Booking_Quoto_Name"] = "Gen"; //Agent Session["Booking_Quoto"] = 1; //Agent } else { Session["Booking_Quoto_Name"] = "Agent"; //Agent Session["Booking_Quoto"] = 2; //Agent } SetVisibilty(); Response.Redirect("~/Default.aspx"); } } else { lblFailureText.Visible = true; lblFailureText.Text = s; //Response.Redirect("~/Default.aspx"); } }
public static void registerLogedInUser(UserAcount user, IPeer peer) { if (users.ContainsKey(user)) { throw new Exception("Trying to register already registered user!"); } users.Add(user, new ActiveUser(user, peer)); }
protected void Bind() { oUserAcount = new UserAcount { Flag = 3, IsActive = false }; oPUserAcount = new PUserAcount(); ds = oPUserAcount.UserAcount(oUserAcount); grdAgent.DataSource = ds; grdAgent.DataBind(); }
public ActionResult Edit(UserAcount account) { if (ModelState.IsValid) { using (CCV_Tables_Context db = new CCV_Tables_Context()) { db.Entry(account).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View()); }
// GET: UserAcounts/Details/5 public ActionResult Details() { var id = User.Identity.GetUserId(); var checkingId = db.UserAcounts.Where(c => c.ApplicationUserId == id).First().UserID; UserAcount userAcount = db.UserAcounts.Find(checkingId); if (userAcount == null) { return(HttpNotFound()); } return(View(userAcount)); }
// GET: UserAcounts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserAcount userAcount = db.UserAcounts.Find(id); if (userAcount == null) { return(HttpNotFound()); } return(View(userAcount)); }
public ActionResult Edit([Bind(Include = "UserID,Name,Age,Phone,Email,ApplicationUserId")] UserAcount userAcount) { var userId = User.Identity.GetUserId(); var checkingStudentId = db.UserAcounts.Where(c => c.ApplicationUserId == userId).First().UserID; if (ModelState.IsValid) { db.Entry(userAcount).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userAcount)); }
//Update Database public ActionResult Edit(int id) { var userAccount = new UserAcount(); if (id > 0) { userAccount = _userAccountManager.GetById(id); var model = Mapper.Map <UserAccountEntryVm>(userAccount); return(View(model)); } return(View()); }
public ActionResult Edit(int?id) { using (CCV_Tables_Context db = new CCV_Tables_Context()) { if (id == null) { return(new HttpStatusCodeResult(BadRequest)); } UserAcount account = db.UserAcounts.Find(id); if (User == null) { return(HttpNotFound()); } return(View(db.UserAcounts.SingleOrDefault(c => c.UserId == id))); } }
public async Task GetDailyShit() { UserAcount userAcount = UserAcounts.GetOrCreateAcount(Context.User.Id); if (DateTime.Now >= userAcount.DailyBucksReset) { userAcount.DailyBucksReset = DateTime.Now.AddDays(1); userAcount.Money += 200; await ReplyAsync("**FART**, Here is your daily Shit! **200 shit bucks received!**"); UserAcounts.SaveAcounts(); } else { TimeSpan Remaining = userAcount.DailyBucksReset - DateTime.Now; await ReplyAsync("Sorry! i cant give it to you yet! i have not taken a shit yet! You gotta wait: " + Remaining.ToString(@"hh\:mm\:ss")); } }
public async Task GiveBallAsync(params string[] args) { UserAcount userAcount = UserAcounts.GetOrCreateAcount(Context.Message.MentionedUsers.First().Id); UserAcount userAcount2 = UserAcounts.GetOrCreateAcount(Context.User.Id); if (userAcount2.Money >= Convert.ToUInt32(args[1])) { userAcount.Money += Convert.ToUInt32(args[1]); userAcount2.Money -= Convert.ToUInt32(args[1]); await ReplyAsync(Context.User.Username + " Just gave " + Context.Message.MentionedUsers.First().Username + " " + args[1] + " Shit Bucks"); UserAcounts.SaveAcounts(); } else { await ReplyAsync("Not enough Shitty Bucks!"); } }
public async Task WorkAsync(params string[] work) { Random random = new Random(); UserAcount userAcount = UserAcounts.GetOrCreateAcount(Context.User.Id); if (DateTime.Now >= userAcount.WorkReset) { userAcount.WorkReset = DateTime.Now.AddMinutes(30); uint Salaris = Convert.ToUInt32(random.Next(10, 50)); userAcount.Money += Salaris; await ReplyAsync("You just worked and received " + Salaris + " Shit bucks!"); UserAcounts.SaveAcounts(); } else { TimeSpan Remaining = userAcount.WorkReset - DateTime.Now; await ReplyAsync("You cant work yet you gotta take a pause! You have to wait: " + Remaining.ToString(@"hh\:mm\:ss")); } }
protected void EditProfile() { oUserAcount = new UserAcount { Flag = 6, UserID = Convert.ToDouble(Session["User_ID"].ToString()), FirstName = txtFirstName.Text, LastName = txtLastName.Text, MobileNo = Convert.ToDouble(txtMobileNo.Text), City = txtCity.Text, Address1 = txtAddress1.Text != string.Empty ? txtAddress1.Text : null, PinCode = txtPinCode.Text != string.Empty ? Convert.ToDouble(txtPinCode.Text) : (double?)null, PanNo = txtPanNo.Text, FaxNo = txtFaxNo.Text != string.Empty ? Convert.ToDouble(txtFaxNo.Text) : (double?)null, OrganizationName = txtOrganizationName.Text, }; oPUserAcount = new PUserAcount(); ds = oPUserAcount.UserAcount(oUserAcount); lblmsg.Visible = true; lblmsg.Text = ds.Tables[0].Rows[0][0].ToString(); }
protected void PrepareEntity(Enum Mode, string par = "") { int UserType = int.Parse(ViewState["RegisterAs"].ToString()); oUserAcount = new UserAcount { Flag = 1, UserType = UserType, FirstName = txtFirstName.Text, LastName = txtLastName.Text, EMail = txtEmail.Text, Password = txtPassword.Text, MobileNo = Convert.ToDouble(txtMobileNo.Text), City = txtCity.Text, Address1 = txtAddress1.Text != string.Empty ? txtAddress1.Text : null, PinCode = txtPinCode.Text != string.Empty ? Convert.ToDouble(txtPinCode.Text) : (double?)null, PanNo = txtPanNo.Text, FaxNo = txtFaxNo.Text != string.Empty ? Convert.ToDouble(txtFaxNo.Text) : (double?)null, OrganizationName = txtOrganizationName.Text, IsActive = UserType != 2 ? true : false }; oPUserAcount = new PUserAcount(); if (Mode.Equals(DMLFlags.Insert)) { ds = oPUserAcount.UserAcount(oUserAcount); } msg.Text = ds.Tables[0].Rows[0][0].ToString(); tblMain.Visible = false; tblSave.Visible = false; tblAgent.Visible = false; pMsgInfo.Visible = false; tblMsg.Visible = true; if (msg.Text.Contains("successfully")) { if (UserType == 2) { msg.Text = msg.Text + " And submitted to site admin for approval."; } } }
public ActionResult Login(UserAcount user) { using (CCV_Tables_Context db = new CCV_Tables_Context()) { bool validEmail = db.UserAcounts.Any(x => x.Username == user.Username); bool validPassword = db.UserAcounts.Any(x => x.Password == user.Password); if (!validEmail) { TempData["alertMessage"] = "Wrong username or password"; return(RedirectToAction("Login")); } if (!validPassword) { TempData["alertMessage"] = "Wrong username or password"; return(RedirectToAction("Login")); } var usr = db.UserAcounts.Single(u => u.Username == user.Username && u.Password == user.Password); if (usr != null) { Session["UserID"] = usr.UserId.ToString(); Session["FirstName"] = usr.FirstName.ToString(); bool admin = (usr.UserId == 1); if (admin) { Session["IsAdmin"] = true; return(RedirectToAction("Index")); } return(RedirectToAction("LoggedIn")); } else { ModelState.AddModelError("", "Ussername or Password is wrong"); } } return(View()); }
protected void ShowProfile() { oUserAcount = new UserAcount { Flag = 5, UserID = Convert.ToInt32(Session["User_ID"].ToString()) }; oPUserAcount = new PUserAcount(); ds = oPUserAcount.UserAcount(oUserAcount); txtFirstName.Text = ds.Tables[0].Rows[0]["FirstName"].ToString(); txtLastName.Text = ds.Tables[0].Rows[0]["LastName"].ToString(); txtEmail.Text = ds.Tables[0].Rows[0]["EMail"].ToString(); txtCity.Text = ds.Tables[0].Rows[0]["City"] != null ? ds.Tables[0].Rows[0]["City"].ToString():string.Empty; txtMobileNo.Text = ds.Tables[0].Rows[0]["MobileNo"].ToString(); txtOrganizationName.Text = ds.Tables[0].Rows[0]["OrganizationName"] != null ? ds.Tables[0].Rows[0]["OrganizationName"].ToString() : string.Empty; txtPinCode.Text = ds.Tables[0].Rows[0]["PinCode"] != null ? ds.Tables[0].Rows[0]["PinCode"].ToString(): string.Empty; txtPanNo.Text = ds.Tables[0].Rows[0]["PanNo"] != null ? ds.Tables[0].Rows[0]["PanNo"].ToString() : string.Empty; txtFaxNo.Text = ds.Tables[0].Rows[0]["FaxNo"] != null ? ds.Tables[0].Rows[0]["FaxNo"].ToString() : string.Empty; txtAddress1.Text = ds.Tables[0].Rows[0]["Address1"] != null ? ds.Tables[0].Rows[0]["Address1"].ToString() : string.Empty; }
public bool Update(UserAcount userAcount) { db.UserAcounts.Attach(userAcount); db.Entry(userAcount).State = EntityState.Modified; return(db.SaveChanges() > 0); }
//login user public UserAcount Login(UserAcount user) { return(db.UserAcounts.FirstOrDefault(u => u.UserName == user.UserName && u.Password == user.Password)); }
//Add Register public bool RegisterAdd(UserAcount userAcount) { db.UserAcounts.Add(userAcount); return(db.SaveChanges() > 0); }
public int AddUser(UserAcount userAcount) { return(0); }
//login register Add public bool Add(UserAcount userAcount) { return(_userAccountRepository.RegisterAdd(userAcount)); }
//login public UserAcount Login(UserAcount userAcount) { return(_userAccountRepository.Login(userAcount)); }
///for update /// public bool Update(UserAcount userAcount) { return(_userAccountRepository.Update(userAcount)); }
public int Post([FromBody] UserAcount userAcount) { return(UserAcountService.AddUser(userAcount)); }
public ActiveUser(UserAcount userAcount, IPeer peer) { this.userAcount = userAcount; this.peer = peer; }