public async Task<ActionResult> DeleteConfirmed(int id) { UsersAccount usersAccount = await db.UsersAccounts.FindAsync(id); db.UsersAccounts.Remove(usersAccount); await db.SaveChangesAsync(); return RedirectToAction("Index"); }
public HttpResponseMessage PutNewPassword(int id, [FromBody] UsersAccount setpassword) { try { using (BankingDbEntities db = new BankingDbEntities()) { var data = db.UsersAccounts.Find(id); if (data == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Account number" + id + " not found")); } else { data.Login_Password = setpassword.Login_Password; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public static UsersAccountDTO ConvertUsersAccountToDTO(UsersAccount u) { return(new UsersAccountDTO { UserId = u.UserId, AccountId = u.AccountId, UserAccountId = u.UserAccountId }); }
private async Task AddUserAccType() { var viewModel = new UserAccountTypeDetailViewModel(new UserAccountTViewModel(), _usersAccountTypeStore, _pageService); viewModel.UserAccountTypeAdded += (source, usersAccount) => { UsersAccount.Add(new UserAccountTViewModel(usersAccount)); }; await _pageService.PushModalAsync(new UserAccountTypeDetailPage(viewModel)); }
public async Task <ActionResult> Edit([Bind(Include = "UserId,FirstName,LastName,Email,UserName,Password,ConfirmPassword")] UsersAccount userAccount) { if (ModelState.IsValid) { db.Entry(userAccount).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } //ViewBag.InstructorID = new SelectList(db.Instructors, "ID", "LastName", department.InstructorID); return(View(userAccount)); }
private async Task DeleteUserAccType(UserAccountTViewModel userAccount) { var a = ""; if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete{userAccount.TypeAndName}?", "Yes", "No")) { UsersAccount.Remove(userAccount); var userAccountType = await _usersAccountTypeStore.GetUsersAccountType(userAccount.Id); await _usersAccountTypeStore.DeleteUserAccountType(userAccountType); } }
public ActionResult Register(UsersAccount account) { if (ModelState.IsValid) { db.UsersAccounts.Add(account); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = account.FirstName + "" + account.LastName + "Successfully Registered"; } return(View()); }
public async Task<ActionResult> Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } UsersAccount usersAccount = await db.UsersAccounts.FindAsync(id); if (usersAccount == null) { return HttpNotFound(); } return View(usersAccount); }
//------------------------------------Details Section-----------------------------------------------------------------------------------------// // GET: Students/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UsersAccount usersAccount = db.UsersAccounts.Find(id); // πήγαινε στη βάση και φέρε μου by id ένα record .. και φτιάχνω ένα απλό Object χωρίς να έχω φτιάξει constructor.Μέσω της Find(); if (usersAccount == null) { return(HttpNotFound()); } return(View(usersAccount)); }
//The parameter is the user id, then we will find all //photos with the same user id public ActionResult MyProfile() { //PhotoViewModel viewModel = new PhotoViewModel(); string userId = User.Identity.GetUserId(); PhotoRepository rep = new PhotoRepository(); UsersAccount model = new UsersAccount(); model.photos = rep.GetUsersPhotos(userId); // Console.WriteLine(viewModel); return(View(model)); }
//------------------------------Edit Section-------------------------------------------------------------------------------// // GET: Departments/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UsersAccount userAccount = await db.UsersAccounts.FindAsync(id); if (userAccount == null) { return(HttpNotFound()); } //ViewBag.InstructorID = new SelectList(db.Instructors, "ID", "LastName", department.InstructorID); return(View(userAccount)); }
public ActionResult Register(UsersAccount account) { if (ModelState.IsValid) { using (AnalyticDbContex db = new AnalyticDbContex()) { db.userAccount.Add(account); db.SaveChanges(); return(RedirectToAction("Login")); } ModelState.Clear(); } return(View()); }
private async Task LoadData() { if (_isDataLoaded) { return; } _isDataLoaded = true; var usersAccount = await _usersAccountTypeStore.GetUsersAccountTypeAsync(); foreach (var u in usersAccount) { UsersAccount.Add(new UserAccountTViewModel(u)); } }
public ActionResult Login(UsersAccount model) { if (ModelState.IsValid) { var dao = new UserDao(); var result = dao.Login(model.UserName, Encrytor.GetMD5(model.Password)); switch (result) { case 1: var userLogin = dao.GetByID(model.UserName); Session.Add(Constrain.User_Session, userLogin); if (model.Remember) { return(RedirectToAction("Index", "Cart")); } if (userLogin.Type != 0) { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Home")); } case 0: ModelState.AddModelError("", "Tài Khoản không tồn tại"); break; case -1: ModelState.AddModelError("", "Tài khoản đã bị khóa"); break; case -2: ModelState.AddModelError("", "Sai mật khẩu"); break; default: ModelState.AddModelError("", "Tên đang nhập mk ko đúng"); break; } } else { ModelState.AddModelError("", "Nhập tên tài khoản mật khẩu"); } return(View("Index")); }
public ActionResult Create([Bind(Include = "UserId,FirstName,LastName,Email,UserName,Password,ConfirmPassword")] UsersAccount usersAccount) // Include σημαίνει ότι έχω φτιάξει συγκεκριμένη whitelist περνόύν δηλαδή μόνο συγκεκριμένοι { //είναι για λόγους ασφαλείας "ID,LastName,FirstName,EnrollmentDate" try { if (ModelState.IsValid) { db.UsersAccounts.Add(usersAccount); db.SaveChanges(); return(RedirectToAction("Index")); //We put a try catch because we might enter wrong data to the database. } } catch (DataException) { ModelState.AddModelError("", "Unable to save Changes"); } return(View(usersAccount)); }
public ActionResult FriendsProfile(string id) { //PhotoViewModel viewModel = new PhotoViewModel(); UserRepository userRep = new UserRepository(); ApplicationUser user = userRep.GetUserByUsername(id); string loggedInUser = User.Identity.GetUserName(); PhotoRepository rep = new PhotoRepository(); UsersAccount model = new UsersAccount(); model.username = id; model.isFollowing = userRep.IsFollowing(loggedInUser, user.UserName); model.photos = rep.GetUsersPhotos(user.Id); // Console.WriteLine(viewModel); return(View("MyProfile", model)); }
//-------------------------------------------------------Delete Section-----------------------------------------------------------------------// // GET: Students/Delete/5 public ActionResult Delete(int?id, bool?saveChangesError = false) // πάει στη βάση βρίσκει ένα student και ρωταέι αν θέλεις να σβηστεί { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator."; } UsersAccount usersAccount = db.UsersAccounts.Find(id); if (usersAccount == null) { return(HttpNotFound()); } return(View(usersAccount)); }
public ActionResult Login(UsersAccount user) { //using (OilProjectDbContext db = new OilProjectDbContext()) //{ //var obj = db.UserProfiles.Where(a => a.UserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).FirstOrDefault(); var usr = db.UsersAccounts.Where(u => u.UserName.Equals(user.UserName) && u.Password.Equals(user.Password)).FirstOrDefault(); /*== user.UserName && u.Password == user.Password); */ if (usr != null) { Session["UserId"] = usr.UserId.ToString(); Session["UserName"] = usr.UserName.ToString(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "UserName or Password is Wrong"); } //} return(View()); }
public ActionResult DeleteConfirmed(int id) { //try //{ // //OLDCODE // //Student student = db.Students.Find(id); // εδώ πάω δυο φορές στη βάση // //db.Students.Remove(student); // //NEW CODE // UsersAccount userToDelete = new UsersAccount() { UserId = id }; // db.Entry(userToDelete).State = EntityState.Deleted; //Φτιάχνω ένα Object student και πάω μια μόνο φορά στη βάση // db.SaveChanges(); //} //catch (DataException) //{ // return RedirectToAction("Delete", new { id = id, saveChangesError = true }); // τα παίρνει απο την από πάνω μέθοδο //} //return RedirectToAction("Index"); // if everything goes well return to index page //UsersAccount user = db.UsersAccounts.Find(id); //Doesn't work because it is also used in class OilPress , thus we have to add extra code UsersAccount users = db.UsersAccounts .Include(i => i.OilPresses) // we use this because the UserId is also used in Oilpresses as foreign key .Where(i => i.UserId == id) .Single(); db.UsersAccounts.Remove(users); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task<ActionResult> Edit(UserAccountViewModel model) { var usersID = User.Identity.GetUserId(); if (usersID == null) { usersID = "0"; } var usersAccount = new UsersAccount { ID = model.ID, UserID = usersID, Transection_Money = model.Transection_Money, TransectionType = model.TransectionType, F_P_AccNo = model.F_P_AccNo, IsApproved_old = model.IsApproved_old, IsApproved_new = model.IsApproved_new, IsFraud_old = model.IsFraud_old, IsFraud_new = model.IsFraud_new, CreditRatingForOne = model.CreditRatingForOne, AccountTypeForOne = model.AccountTypeForOne, TransectionDate = model.TransectionDate, UserIPAddress = model.UserIPAddress }; if (ModelState.IsValid) { db.Entry(usersAccount).State = EntityState.Modified; await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(usersAccount); }
public async Task <IActionResult> MyItemsPost(string Id, List <IFormFile> files) { PurchasedItems currentPurchase = new PurchasedItems(); int currentID = Int32.Parse(Id); var Currentitem = _context.PurchasedItems.Where(x => x.Id == currentID).Select(x => x).ToList(); byte[] image = new byte[12]; if (ModelState.IsValid) { foreach (var item in files) { if (item.Length > 0) { using (var stream = new MemoryStream()) { await item.CopyToAsync(stream); image = stream.ToArray(); } } } using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); // 1.create a command object identifying the stored procedure SqlCommand cmd = new SqlCommand("CompletePurchase", conn); // 2.set the command object so it knows to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; // 3.add parameter to command, which will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@Id", Int32.Parse(Id))); cmd.Parameters.Add(new SqlParameter("@Image", image)); // execute the command cmd.ExecuteNonQuery(); } SellersItems refundedItem = _context.SellersItems.Where(x => x.Id == Currentitem[0].ItemId).FirstOrDefault(); UsersAccount buyerId = _context.UsersAccount.Where(x => x.Id == Currentitem[0].BuyerId).FirstOrDefault(); MailMessage mail = new MailMessage("*****@*****.**", buyerId.Email); SmtpClient client = new SmtpClient(); client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = true; client.Credentials = new NetworkCredential("*****@*****.**", "Password1234!"); client.EnableSsl = true; client.Host = "smtp.gmail.com"; mail.Subject = "You have refund for<b> " + refundedItem.ItemName + "!</b>"; mail.IsBodyHtml = true; mail.Body = "<h3>Hi " + buyerId.Email + "</h3><br>" + "<br><p><b>You have refund for :</b> " + refundedItem.ItemName + "</p>" + "<br><p>Please login to our service to see refund screenshot.</p>" + "<br><p>Thank you for using our service.<p>" + "<p><b>Reviews Trade Team.</b><p>"; client.Send(mail); } return(RedirectToAction("Index", "Home")); }
//public async Task<ActionResult> Create([Bind(Include = "ID,UserID,Transection_Money,TransectionType,F_P_AccNo,IsApproved_old,IsApproved_new,IsFraud_old,IsFraud_new,CreditRatingForOne")] UsersAccount usersAccount) public async Task<ActionResult> Create(UserAccountViewModel model) { var usersID = User.Identity.GetUserId(); if (usersID == null) { usersID = "0"; } //IP Address var ip = Request.UserHostAddress; //Is any high risk ip address as same as user IP Address(For User Sight) bool isUserHighRisk = db.RiskIPs.Any(s => s.HighRiskIP == ip); //Is any high risk ip address as same as user IP Address(For Sight) // We can't select all because if receiver once use with high risk ip then he affected everytime for this so that's why we use only last IP for check string accountIP = db.UsersAccounts.Where(s => s.F_P_AccNo == model.F_P_AccNo).OrderByDescending(s=>s.ID).Select(s => s.UserIPAddress).FirstOrDefault(); bool isReceiverHighRisk = db.RiskIPs.Any(s => s.HighRiskIP == accountIP); //Got Account Type var accountType = db.Users.Where(s => s.Id == usersID).Select(s => s.AccountType).FirstOrDefault(); // Credit Avg on other method var creditAvg = CreditRatio(accountType); var usersAccount = new UsersAccount(); if(isUserHighRisk == true) { ViewBag.Message = "Your IP address is high risk. you can't transtion any money"; } else { if (isReceiverHighRisk == true) { ViewBag.Message = "Your Receiver IP address is high risk. you can't transtion any money"; } else { if (creditAvg > Convert.ToDouble(model.Transection_Money)) { var isFraud = Algorithm(accountType, model.TransectionType, "Normal"); if (isFraud == true) { model.IsApproved_old = false; } else { model.IsApproved_old = true; } usersAccount = new UsersAccount { ID = model.ID, UserID = usersID, Transection_Money = model.Transection_Money, TransectionType = model.TransectionType, F_P_AccNo = model.F_P_AccNo, IsApproved_old = model.IsApproved_old, IsApproved_new = model.IsApproved_old, IsFraud_old = isFraud, IsFraud_new = isFraud, CreditRatingForOne = "Normal", AccountTypeForOne = accountType, TransectionDate = DateTime.Now.ToString("MM/dd/yyyy"), UserIPAddress = ip }; if (ModelState.IsValid) { if(isFraud == true) { ViewBag.Message = "You transection has been blocked. Please contact with admin."; } db.UsersAccounts.Add(usersAccount); await db.SaveChangesAsync(); //return RedirectToAction("Create"); } } else { var isFraud = Algorithm(accountType, model.TransectionType, "Extra"); if (isFraud == true) { model.IsApproved_old = false; } else { model.IsApproved_old = true; } usersAccount = new UsersAccount { ID = model.ID, UserID = usersID, Transection_Money = model.Transection_Money, TransectionType = model.TransectionType, F_P_AccNo = model.F_P_AccNo, IsApproved_old = model.IsApproved_old, IsApproved_new = model.IsApproved_old, IsFraud_old = isFraud, IsFraud_new = isFraud, CreditRatingForOne = "Extra", AccountTypeForOne = accountType, TransectionDate = DateTime.Now.ToString("MM/dd/yyyy"), UserIPAddress = ip }; if (ModelState.IsValid) { db.UsersAccounts.Add(usersAccount); await db.SaveChangesAsync(); if (isFraud == true) { ViewBag.Message = "You transection has been blocked. Please contact with admin."; } //return RedirectToAction("Create"); } } } } return View(usersAccount); }
public bool Equals(UsersAccount x, UsersAccount y) { return(x.UserId == y.UserId); }
public int GetHashCode(UsersAccount obj) { return(obj.UserId.GetHashCode()); }
public async Task <IActionResult> PurchaseItemPost(string orderNum, string paypal, int itemId, int sellerId, List <IFormFile> files) { PurchasedItems currentPurchase = new PurchasedItems(); currentPurchase.OrderNumber = orderNum; currentPurchase.Ppemail = paypal; currentPurchase.DateOfPurchased = DateTime.Now; currentPurchase.ItemId = itemId; currentPurchase.SellerId = sellerId; currentPurchase.BuyerId = Int32.Parse(HttpContext.Session.GetString("Id")); currentPurchase.Status = "pending"; if (ModelState.IsValid) { foreach (var item in files) { if (item.Length > 0) { using (var stream = new MemoryStream()) { await item.CopyToAsync(stream); currentPurchase.ScreenShoot = stream.ToArray(); } } } _context.Add(currentPurchase); await _context.SaveChangesAsync(); var itemToUpdate = _context.SellersItems.Where(x => x.Id == itemId).Select(x => x); int?HowmanyReviews = 0; foreach (var item in itemToUpdate) { HowmanyReviews = item.ReviesNeeded - 1; } using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); // 1.create a command object identifying the stored procedure SqlCommand cmd = new SqlCommand("ReviewsNeeded", conn); // 2.set the command object so it knows to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; // 3.add parameter to command, which will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@number", HowmanyReviews)); cmd.Parameters.Add(new SqlParameter("@Id", itemId)); // execute the command cmd.ExecuteNonQuery(); } ReviewsContext db = new ReviewsContext(); UsersAccount seller = db.UsersAccount.ToList().Where(x => x.Id == sellerId).FirstOrDefault(); SellersItems soldItem = db.SellersItems.ToList().Where(x => x.Id == itemId).FirstOrDefault(); MailMessage mail = new MailMessage("*****@*****.**", seller.Email); SmtpClient client = new SmtpClient(); client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = true; client.Credentials = new NetworkCredential("*****@*****.**", "Password1234!"); client.EnableSsl = true; client.Host = "smtp.gmail.com"; mail.To.Add("add more peoples..."); mail.Subject = "You have Sold " + soldItem.ItemName + "!"; mail.IsBodyHtml = true; mail.Body = "<h3>Hi " + seller.Email + "</h3><br>" + "<br><p><b>You have sold :</b> " + soldItem.ItemName + "</p>" + "<b>Order number : </b>" + orderNum + "<br><p>we will let you know once review will be live.</p>" + "<br><p>Thank you for using our service<p>" + "<p><b>Reviews Trade Team.</b><p>"; client.Send(mail); return(RedirectToAction("MyItems", "PurchasedItem")); } return(View()); }
public UsersAccount CreateUserAccount(UsersAccount user) { return(_respository.Insert(user)); }