// GET: Orders/Create public async Task <IActionResult> BuyIt(int id = 0) { Order order = new Order(); if (id == 0) { return(NotFound()); } var book = _context.Book.Include(b => b.BookCondition).Include(b => b.StudyArea).Where(b => b.BookId == id).First(); if (book == null) { return(NotFound()); } order.BookId = id; order.CreationDate = DateTime.Now; order.PaymentForm = "c"; order.Price = book.Price; order.Quantity = 1; order.SellerId = book.UserId; order.UserId = HelperUser.GetUserId(this.User.Identity.Name, _context); ViewData["BookTitle"] = book.Title; ViewData["StudyArea"] = book.StudyArea.StudyAreaName; ViewData["BookCondition"] = book.BookCondition.Condition; ViewData["MaxQty"] = book.Quantity; //ViewData["BookId"] = new SelectList(_context.Book, "BookId", "ISBN", order.BookId); //ViewData["UserId"] = new SelectList(_context.User, "UserId", "CreditcardName", order.UserId); return(View(order)); }
// GET: Orders/Create public IActionResult Create() { if (HelperUser.isAdministrator(this.User.Identity.Name)) { ViewData["BookId"] = new SelectList(_context.Book, "BookId", "ISBN"); ViewData["UserId"] = new SelectList(_context.User, "UserId", "CreditcardName"); return(View()); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Index() { int UserId = HelperUser.GetUserId(this.User.Identity.Name, _context); var seboDbContext = _context.Book.Include(b => b.BookCondition) .Include(b => b.StudyArea) .Include(b => b.User) .Where(b => HelperUser.isAdministrator(this.User.Identity.Name) || String.IsNullOrEmpty(this.User.Identity.Name) ? b.UserId > 0 : b.UserId != UserId) .Where(b => b.Quantity > b.QuantitySold); return(View(await seboDbContext.ToListAsync())); }
// GET: Orders public async Task <IActionResult> Index() { int userId = HelperUser.GetUserId(this.User.Identity.Name, _context); var seboDbContext = _context.Order.Include(o => o.Book).Include(o => o.User) .Where(o => HelperUser.isAdministrator(this.User.Identity.Name)? o.UserId > 0 : o.UserId == userId || HelperUser.isAdministrator(this.User.Identity.Name) ? o.SellerId > 0 : o.SellerId == userId ); return(View(await seboDbContext.ToListAsync())); }
User SearchUserWithName() { var users = HelperUser.GetUsers(); foreach (var user in users) { if (user.Name == textBoxUserName.Text) { loggedInUserID = user.ID; return(user); } } return(null); }
private void BtnGiris_Click(object sender, EventArgs e) { ///Kullanıcı girişi veritabanından text boxtaki verileri gönderecek bir metod ///KullaniciGiris(txtuser, txtpass); if (txtUsername.Text == "" || txtPassword.Text == "") { MessageBox.Show("Eksik Bilgi Girdiniz. Lütfen Tekrar Deneyin.", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { HelperUser h = new HelperUser(); var b = h.StudentUser(txtUsername.Text, txtPassword.Text); if (b != null) { if (b.Type.Value == Convert.ToInt32(Style.ogrenci)) { Form2 f2 = new Form2(b.Ogrt_ogrID.Value, b.Type.Value); f2.Show(); this.Hide(); } else if (b.Type.Value == Convert.ToInt32(Style.admin)) { Form3 f3 = new Form3(b.Ogrt_ogrID.Value); f3.Show(); this.Hide(); } else if (b.Type.Value == Convert.ToInt32(Style.ogretmen)) { Form4 f4 = new Form4(b.Ogrt_ogrID.Value); HelperOgretmen ho = new HelperOgretmen(); var ogrt = ho.GetOgretmen(b.Ogrt_ogrID.Value); f4.Text = ogrt.OgretmenAdi; f4.Show(); this.Hide(); } } else { MessageBox.Show("Hatalı Giriş Yaptınız. Lütfen Tekrar Deneyin.", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Clear(); txtPassword.Clear(); } } }
// GET: Orders/Edit/5 public async Task <IActionResult> Edit(int?id) { if (!HelperUser.isAdministrator(this.User.Identity.Name)) { return(RedirectToAction("Index")); } if (id == null) { return(NotFound()); } var order = await _context.Order.FindAsync(id); if (order == null) { return(NotFound()); } ViewData["BookId"] = new SelectList(_context.Book, "BookId", "ISBN", order.BookId); ViewData["UserId"] = new SelectList(_context.User, "UserId", "CreditcardName", order.UserId); return(View(order)); }
// GET: Orders/Delete/5 public async Task <IActionResult> Delete(int?id) { if (!HelperUser.isAdministrator(this.User.Identity.Name)) { return(RedirectToAction("Index")); } if (id == null) { return(NotFound()); } var order = await _context.Order .Include(o => o.Book) .Include(o => o.User) .FirstOrDefaultAsync(m => m.OrderId == id); if (order == null) { return(NotFound()); } return(View(order)); }
// GET: Books public async Task <IActionResult> BooksCatalog(string UserName, string sortOrder, string currentSearchString, string SearchString, int StudyAreaFilter, int BookConditionFilter, int?Page) { if (currentSearchString != null) { string[] m = currentSearchString.Split("."); currentSearchString = m[0]; // preserves the current filter typed within the search textbox if (SearchString == null) { SearchString = currentSearchString; } if (StudyAreaFilter == 0) { StudyAreaFilter = Int32.Parse(m[1]); // preserves the select institution option in the dropdownlist } if (BookConditionFilter == 0) { BookConditionFilter = Int32.Parse(m[2]); // preserves the select Study Area option in the dropdownlist } } //Get the User ID int UserId = HelperUser.GetUserId(this.User.Identity.Name, _context); int UserBranchId = HelperUser.GetUserBranchId(this.User.Identity.Name, _context); // Cheks whether a search string was typed and prepares for search by each word string[] myString = SearchString != null?SearchString.Trim().Split(" ") : new string[0]; // Get the seach's recordset already sorted var books = StringSearch.SearchBook(_context, sortOrder, myString).Include(b => b.BookCondition).Include(b => b.StudyArea).Include(b => b.User) .Where(b => !b.Blocked) .Where(b => b.Quantity > b.QuantitySold) .Where(b => b.UserId != UserId) .Where(b => !b.IsWaitList); var users = (from u in _context.User select u).Include(u => u.InstitutionBranch); //Getting the books from the same institution var books2 = (from b in books join u in users on b.UserId equals u.UserId select new { b.Blocked, b.BookCondition, b.BookConditionId, b.BookId, b.CreationDate, b.Description, b.Edition, b.ISBN, b.IsWaitList, b.Orders, b.PhotoFileName, b.Price, b.Publisher, b.Quantity, b.QuantitySold, b.StudyArea, b.StudyAreaId, b.Title, b.User, b.UserId, b.Visualizations, u.InstitutionBranchId, u.InstitutionBranch.InstitutionBranchName }).Where(b => b.InstitutionBranchId == UserBranchId); // Applying filters on the table if (StudyAreaFilter != 0) { books2 = books2.Where(b => b.StudyAreaId == StudyAreaFilter); } if (BookConditionFilter != 0) { books2 = books2.Where(b => b.BookConditionId == BookConditionFilter); } // // Preparing Dropboxes // var StudyAreas = (from s in books2 orderby s.StudyArea.StudyAreaName select new { s.StudyAreaId, s.StudyArea.StudyAreaName }).ToList().Distinct(); var BookConditions = (from b in books2 orderby b.BookCondition select new { b.BookConditionId, b.BookCondition.Condition }).ToList().Distinct(); ViewData["StudyAreaFilter"] = new SelectList(StudyAreas, "StudyAreaId", "StudyAreaName"); ViewData["BookConditionFilter"] = new SelectList(BookConditions, "BookConditionId", "Condition"); ////////////////////////////////////// ViewData["CurrentSearchString"] = SearchString + "." + StudyAreaFilter + "." + BookConditionFilter + "." + Page; ViewData["SearchString"] = SearchString; // // Just tracking which ordering column was trigged for setting the actual ordering // ViewData["Title"] = OrderingBooks.NewOrder(sortOrder, "Title"); ViewData["StudyArea"] = OrderingBooks.NewOrder(sortOrder, "StudyArea"); ViewData["BookCondition"] = OrderingBooks.NewOrder(sortOrder, "BookCondition"); ViewData["ISBN"] = OrderingBooks.NewOrder(sortOrder, "ISBN"); ViewData["Price"] = OrderingBooks.NewOrder(sortOrder, "Price"); int PageSize = 14; return(View(await Pagination <Book> .CreateAsync(books.AsNoTracking(), Page ?? 1, PageSize))); }
public async Task <IActionResult> Index(string UserName, string sortOrder, string currentSearchString, string SearchString, int StudyAreaFilter, int BookConditionFilter, int?Page) { if (currentSearchString != null) { string[] m = currentSearchString.Split("."); currentSearchString = m[0]; // preserves the current filter typed within the search textbox if (SearchString == null) { SearchString = currentSearchString; } if (StudyAreaFilter == 0) { StudyAreaFilter = Int32.Parse(m[1]); // preserves the select institution option in the dropdownlist } if (BookConditionFilter == 0) { BookConditionFilter = Int32.Parse(m[2]); // preserves the select Study Area option in the dropdownlist } } //Get the User ID if (String.IsNullOrEmpty(UserName)) { UserName = this.User.Identity.Name; } int UserId = HelperUser.GetUserId(UserName, _context); // Cheks whether a search string was typed and prepares for search by each word string[] myString = SearchString != null?SearchString.Trim().Split(" ") : new string[0]; var x = HelperUser.isAdministrator(UserName); // Get the seach's recordset already sorted applying filtering according to user role var books = StringSearch.SearchBook(_context, sortOrder, myString).Include(b => b.BookCondition).Include(b => b.StudyArea).Include(b => b.User) .Where(b => !b.Blocked) .Where(b => b.Quantity > b.QuantitySold) .Where(b => !b.IsWaitList) .Where(b => HelperUser.isAdministrator(UserName) ? b.UserId > 0 : b.UserId == UserId); //.Where(b => UserId > 0 || UserName != null ? b.UserId == UserId : b.UserId > 0) // Applying filters on the table if (StudyAreaFilter != 0) { books = books.Where(b => b.StudyAreaId == StudyAreaFilter); } if (BookConditionFilter != 0) { books = books.Where(b => b.BookConditionId == BookConditionFilter); } // // Preparing Dropboxes // var StudyAreas = (from s in books orderby s.StudyArea.StudyAreaName select new { s.StudyAreaId, s.StudyArea.StudyAreaName }).ToList().Distinct(); var BookConditions = (from b in books orderby b.BookCondition select new { b.BookConditionId, b.BookCondition.Condition }).ToList().Distinct(); ViewData["StudyAreaFilter"] = new SelectList(StudyAreas, "StudyAreaId", "StudyAreaName"); ViewData["BookConditionFilter"] = new SelectList(BookConditions, "BookConditionId", "Condition"); ////////////////////////////////////// ViewData["CurrentSearchString"] = SearchString + "." + StudyAreaFilter + "." + BookConditionFilter + "." + Page; ViewData["SearchString"] = SearchString; // // Just tracking which ordering column was trigged for setting the actual ordering // ViewData["Title"] = OrderingBooks.NewOrder(sortOrder, "Title"); ViewData["StudyArea"] = OrderingBooks.NewOrder(sortOrder, "StudyArea"); ViewData["BookCondition"] = OrderingBooks.NewOrder(sortOrder, "BookCondition"); ViewData["ISBN"] = OrderingBooks.NewOrder(sortOrder, "ISBN"); ViewData["Price"] = OrderingBooks.NewOrder(sortOrder, "Price"); int PageSize = 14; return(View(await Pagination <Book> .CreateAsync(books.AsNoTracking(), Page ?? 1, PageSize))); }
private void Button_Save_Click(object sender, RoutedEventArgs e) { try { List <Label> listLableContact = new List <Label>(); listLableContact.Add(HelperUser.FindChild <Label>(Application.Current.MainWindow, "L_ContactPhone3")); listLableContact.Add(HelperUser.FindChild <Label>(Application.Current.MainWindow, "L_ContactPhone3")); // Contact men M_Names contactManNames = new M_Names { NameFirst = TB_FN.Text, NameLast = TB_SN.Text, NameThird = TB_TN.Text }; M_Phones contacPhones = new M_Phones { PhoneNumber = TB_ContacnManPhone.Text + "," + listLableContact[0].Content.ToString() + "," + listLableContact[1].Content.ToString() }; List <M_Names> contactManNamesList = new List <M_Names>(); contactManNamesList.Add(contactManNames); List <M_Phones> phonesContactMan = new List <M_Phones>(); phonesContactMan.Add(contacPhones); List <M_Users> listUser = new List <M_Users>(); M_Users contactUserTextBox = new M_Users { P_Names = contactManNamesList, Address = TB_UsesrAddr.Text, P_Phones = phonesContactMan }; listUser.Add(contactUserTextBox); List <Label> listLable = new List <Label>(); listLable.Add(HelperUser.FindChild <Label>(Application.Current.MainWindow, "L_Contact1")); listLable.Add(HelperUser.FindChild <Label>(Application.Current.MainWindow, "L_Contact2")); foreach (Label tempLab in listLable) { if (tempLab != null) { List <M_Names> contactManNamesListLabel = new List <M_Names>(); List <M_Phones> phonesContactManLabel = new List <M_Phones>(); string contentSecond = tempLab.Content.ToString(); string[] split; split = contentSecond.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries); M_Names contactManNamesAdd = new M_Names { NameFirst = split[0], NameLast = split[1], NameThird = split[2] }; contactManNamesListLabel.Add(contactManNamesAdd); for (int i = 3; i < split.Length; i++) { M_Phones phone = new M_Phones() { PhoneNumber = split[i] }; phonesContactManLabel.Add(phone); } M_Users contactUser = new M_Users { P_Names = contactManNamesListLabel, Address = TB_UsesrAddr.Text, P_Phones = phonesContactManLabel }; listUser.Add(contactUser); } } // Address string address = TB_UsesrAddr.Text; // Birthday DateTime?birth = DP_UserBithday.SelectedDate; // Phones List <M_Phones> userPhones = new List <M_Phones>(); foreach (string item in pnoneNumbersUser) { userPhones.Add(new M_Phones { PhoneNumber = item }); } // Department M_Names departmentName = new M_Names { NameFirst = TB_DepFN.Text, NameLast = TB_DepSN.Text, NameThird = TB_DepTN.Text }; List <M_Names> departmentNames = new List <M_Names>(); departmentNames.Add(departmentName); List <M_Phones> directorPhones = new List <M_Phones>(); foreach (string item in pnoneNumbersDirector) { directorPhones.Add(new M_Phones { PhoneNumber = item }); } M_Departments department = new M_Departments { CodeFull = TB_DepCode.Text, Name = TB_DepName.Text, DepartmentDirectorName = departmentNames, DepartmentDirectorPhone = directorPhones }; // User M_Names contactManNamess = new M_Names { NameFirst = TB_UserFN.Text, NameLast = TB_UserSN.Text, NameThird = TB_UserTN.Text }; List <M_Names> pName = new List <M_Names>(); pName.Add(contactManNamess); List <M_Users> contactMan = new List <M_Users>(); // contactMan.Add(); M_Users user = new M_Users(); user.P_Names = pName; user.Address = address; user.D_Birth = birth; user.P_ManForContact = listUser; user.P_Phones = userPhones; bool isNoFind = true; foreach (var dep in db.C_Departments) { if (dep.Name == department.Name && dep.CodeFull == department.CodeFull) { dep.P_Users.Add(user); isNoFind = false; break; } } if (isNoFind) { user.P_Departments = department; } user.IsUser = true; M_Rfids rFids = new M_Rfids(); rFids.RfidID = Convert.ToInt64(ShowRfid.Text); rFids.Date = DateTime.Now; user.P_Rfids = new List <M_Rfids>(); user.P_Rfids.Add(rFids); // Image string imagepath = ((BitmapImage)imgPhoto.Source).UriSource.AbsolutePath; var imageFile = new FileInfo(imagepath); string imageName = string.Empty; if (imageFile.Exists)// check image file exist { imageName = string.Format("{0}_{1}_{2}.{3}", user.ID.ToString(), TB_UserFN.Text.Replace(" ", string.Empty), TB_UserSN.Text.Replace(" ", string.Empty), imageFile.ToString().Split('.').Last() ); // get your application folder var applicationPath = Directory.GetCurrentDirectory(); // get your 'Uploaded' folder var dir = new DirectoryInfo(System.IO.Path.Combine(applicationPath, "Photos")); if (!dir.Exists) { dir.Create(); } // Copy file to your folder imageFile.CopyTo(System.IO.Path.Combine(dir.FullName, imageName)); } user.Photo = imageName; DateTime start = new DateTime(2000, 01, 01); DateTime and = new DateTime(2000, 01, 01); DateTime valid = new DateTime(2000, 01, 01); TimeSpan start1 = TimeSpan.Parse(TB_Start.Text); TimeSpan and1 = TimeSpan.Parse(TB_And.Text); TimeSpan valid1 = TimeSpan.Parse(TB_Valid.Text); start += (start1); and += (and1); valid += (valid1); M_InOutValidTimes time = new M_InOutValidTimes { Start = start, And = and, Valid = valid }; user.P_InOutValidTimes = time; db.C_Users.Add(user); db.SaveChanges(); } catch (Exception ex) { throw; } UserInfo_Main p = new UserInfo_Main(); this.NavigationService.Navigate(p); }