public async Task <IActionResult> Index() { var indexView = new IndexView(); var projects = await _projectRepository.GetAllProjects(); if (projects.Count == 0) { return(View("~/Views/Home/NoProjectsInSystem.cshtml")); } indexView.Projects = projects; bool isAuthenticated = User.Identity.IsAuthenticated; if (!isAuthenticated) { indexView.UserProjects = null; return(View(indexView)); } string userEmail = User.Claims?.ToList().FirstOrDefault(c => c.Type.Equals(ClaimTypes.Email))?.Value; var userProjects = await _projectRepository.GetUserProjects(userEmail); indexView.UserProjects = userProjects; return(View(indexView)); }
public IActionResult AddPublisher(Publisher formPublisher) { ViewData["Message"] = "Your application description page."; if (ModelState.IsValid) { // add publisher _context.Publishers.Add(formPublisher); _context.SaveChanges(); return(RedirectToAction("Index")); } else { // display the error messages IndexView PublisherErrors = new IndexView() { FormPublisher = formPublisher, AllAuthors = _context.Authors.Include(author => author.Books).ToList(), AllBooks = _context.Books.Include(book => book.Author).Include(book => book.HasPublishers).ThenInclude(Publication => Publication.Publisher).ToList(), AllPublishers = _context.Publishers.Include(publisher => publisher.HasBooks).ThenInclude(publication => publication.Book).ToList() }; return(View("Index", PublisherErrors)); } // for delete // Publisher PublisherToChange = _context.Publishers.FirstOrDefault(Publisher => Publisher.Name.Contains("Dave")); // _context.Publishers.Remove(PublisherToChange); }
public IActionResult AddBook(Book formBook) { if (ModelState.IsValid) { // find the author object to add to the book Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine($"author id is {formBook.AuthorId}"); Console.WriteLine(formBook.Title); Console.WriteLine($"book instance is: {formBook}"); Console.WriteLine($"book title is {formBook.Title}"); Author author = _context.Authors.SingleOrDefault(a => a.AuthorId == formBook.AuthorId); // Author author = _context.Authors.SingleOrDefault(a => a.AuthorId == 2); // set the book author field the the author instance formBook.Author = author; // add the book _context.Books.Add(formBook); // save the book _context.SaveChanges(); return(RedirectToAction("Index")); } else { // display the errors IndexView AuthorErrors = new IndexView() { FormBook = formBook, AllAuthors = _context.Authors.Include(author => author.Books).ToList(), AllBooks = _context.Books.Include(book => book.Author).ToList() }; return(View("Index", AuthorErrors)); } }
public IActionResult AddPublication(Publication formPublication) { ViewData["Message"] = "Your application description page."; if (ModelState.IsValid) { // find the book obj from id, then assign it to the FormPublication's model field Book formPublication.Book = _context.Books.SingleOrDefault(b => b.BookId == formPublication.BookId); // find the publisher obj from id, then assign it to the FormPublication's model field Publisher formPublication.Publisher = _context.Publishers.SingleOrDefault(b => b.PublisherId == formPublication.PublisherId); // add the entire FormPublication object into your db _context.Publications.Add(formPublication); _context.SaveChanges(); return(RedirectToAction("Index")); } else { // display the error messages IndexView PublicationErrors = new IndexView() { FormPublication = formPublication, AllPublications = _context.Publications.Include(Publication => Publication.Publisher).ThenInclude(Publisher => Publisher.HasBooks).ToList(), AllBooks = _context.Books.Include(book => book.Author).Include(book => book.HasPublishers).ThenInclude(Publication => Publication.Publisher).ToList(), AllPublishers = _context.Publishers.Include(publisher => publisher.HasBooks).ThenInclude(publication => publication.Book).ToList() }; return(View("Index", PublicationErrors)); } // for delete // Publication PublicationToChange = _context.Publications.FirstOrDefault(Publication => Publication.Name.Contains("Dave")); // _context.Publications.Remove(PublicationToChange); }
public PartialViewResult GetIndexArticle() { try { var news_articles = (from n in db.news from i in db.images where i.news_article_id == n.id && i.is_main == 1 orderby n.pub_date descending select new { n, i }).Take(3); IndexView indexview = new IndexView(); List <image> img = new List <image>(); List <news> news = new List <news>(); foreach (var article in news_articles) { img.Add(article.i); news.Add(article.n); } indexview.image = img; indexview.news = news; return(PartialView("~/Views/news_partials/_IndexArticles.cshtml", indexview)); } catch (Exception e) { ViewBag.ErrorMssg = e.Message; } return(PartialView("~/Views/Shared/_ErrorMssg.cshtml")); }
// // GET: /Home/ public ActionResult Index() { //1.查看session是否已经有用户登录 HttpCookie cookie = Request.Cookies.Get("UserId"); IndexView indexViewModel = new IndexView(); if (Session["UserId"] != null) { indexViewModel.LoginState = "yes"; indexViewModel.UserId = Session["UserId"].ToString(); } //2.看cookie是否保存有用户登录信息 else if (cookie != null) { indexViewModel.LoginState = "yes"; Session["UserId"] = cookie.Value; indexViewModel.UserId = Session["UserId"].ToString(); } else { indexViewModel.LoginState = "no"; } //3.查询用户昵称 if (indexViewModel.UserId != null) { string sql = "select Name from PM24_Users where UserId=@UserId"; SqlParameter[] param = { new SqlParameter("@UserId", SqlDbType.VarChar, 20) { Value = indexViewModel.UserId } }; indexViewModel.Name = SQLHelper.ExecuteScalar(sql, CommandType.Text, param); } return(View(indexViewModel)); }
public ActionResult Index() { //var listakorisnika = PublicConnection.conn.GetList<Users>("where aktivan = 1"); var ulogirani = System.Web.HttpContext.Current.Session["userName"]; if (ulogirani == null) { return(View("Login")); } else { var IndexModel = new IndexView { UsersCount = DBHelper.GetActiveUsersCount(), UsersList = new List <Users>(), ClanarineList = new List <ClanarineVSUsers>() }; var UserListTemp = DBHelper.GetActiveUsersList(); IndexModel.UsersList = UserListTemp.ToList(); IndexModel.ClanarineList = DBHelper.GetClanarineList(); return(View(IndexModel)); } }
static void Main(string[] args) { if (ArgumentChecker.CheckArguments(args)) { IConfigurationBuilder configurationBuilder = new ConfigurationBuilderImpl(); ArgumentHandler argHandler = new DefaultHandler(); for (int i = 0; i < args.Length; i += 2) { argHandler.HandleArgument(new Tuple <string, string>(args[i], args[i + 1]), configurationBuilder); } ConfigurationBuildDirector configurationBuildDirector = new ConfigurationBuildDirector(configurationBuilder); Configuration configuration = configurationBuildDirector.Construct(); if (!configuration.IsConfigurationValid()) { Console.WriteLine("Argumenti nisu valjani! Provjerite argumente!"); return; } Router.Initialize(configuration); IndexModel indexModel = new IndexModel(); IndexView indexView = new IndexView(configuration); indexView.Initialize(indexModel); indexModel.Attach(indexView); indexView.MakeController(); indexView.Activate(); } }
private Form GetViewByName(string viewName) { if (views.ContainsKey(viewName)) { return(views[viewName]); } switch (viewName) { case "indexView": IndexView indexView = new IndexView(); views.Add(viewName, indexView); return(views[viewName]); case "setAdminView": SetAdminView setAdminView = new SetAdminView(); views.Add(viewName, setAdminView); return(views[viewName]); case "contentView": ContentView contentView = new ContentView(); views.Add(viewName, contentView); return(views[viewName]); default: return(null); } }
public IActionResult Index(int user_id) { int?UserId = HttpContext.Session.GetInt32("UserId"); if (UserId == null) { TempData["InvalidUser"] = "******"; return(RedirectToAction("Login")); } if (user_id != (int)UserId) { TempData["InvalidUser"] = "******"; HttpContext.Session.Clear(); return(RedirectToAction("Login")); } User User = _context.Users.Include(u => u.Transactions).FirstOrDefault(u => u.UserId == UserId); IndexView IndexView = new IndexView() { User = User }; return(View(IndexView)); }
public IActionResult CreateUserAssociation(int MessageId) { int UserId = (int)HttpContext.Session.GetInt32("UserId"); int mid = MessageId; Associations Likes = new Associations() { MessageId = MessageId, UserId = UserId }; if (ModelState.IsValid) { _dbConnector.Add(Likes); _dbConnector.SaveChanges(); System.Console.WriteLine("added"); return(RedirectToAction("Success")); } else { IndexView viewindex = new IndexView() { AllMessages = _dbConnector.Messsages .Include(Message => Message.Creator) .Include(Message => Message.Likes).ThenInclude(Associations => Associations.Users) .ToList(), AllUsers = _dbConnector.Users.ToList() }; ViewBag.Name = HttpContext.Session.GetString("Name"); ViewBag.Alias = HttpContext.Session.GetString("Alias"); ViewBag.UserId = HttpContext.Session.GetInt32("UserId"); System.Console.WriteLine("notadded"); return(View("success", viewindex)); } }
public IActionResult AddBook(Book Book) { if (ModelState.IsValid) { _context.Add(Book); _context.SaveChanges(); return(RedirectToAction("Index")); } else { IndexView DataToIndex = new IndexView() { Authors = _context.Authors .Include(a => a.Wrote) .ThenInclude(b => b.Publications) .ToList(), Books = _context.Books .Include(b => b.Publications) .ThenInclude(p => p.Publisher) .ToList(), Publishers = _context.Publishers.ToList() }; return(View("Index", DataToIndex)); } }
public async Task <IActionResult> Index() { var model = new IndexView(); model.Department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId); model.Profile = _departmentProfileService.GetOrInitializeDepartmentProfile(DepartmentId); model.ImageUrl = $"{Config.SystemBehaviorConfig.ResgridApiBaseUrl}/api/v3/Avatars/Get?id={model.Profile.DepartmentId}&type=1"; var posts = _departmentProfileService.GetArticlesForDepartment(model.Profile.DepartmentProfileId); var visiblePosts = _departmentProfileService.GetVisibleArticlesForDepartment(model.Profile.DepartmentProfileId); if (visiblePosts != null && visiblePosts.Any()) { model.VisiblePosts = visiblePosts.Count; } if (posts.Any()) { model.Posts = posts.Skip(Math.Max(0, posts.Count() - 3)).ToList(); } else { model.Posts = new List <DepartmentProfileArticle>(); } return(View(model)); }
public IActionResult PostMessage(IndexView Data) { Messages NewMessage = Data.NewMessage; if (ModelState.IsValid) { _dbConnector.Add(NewMessage); _dbConnector.SaveChanges(); System.Console.WriteLine("Message success"); return(RedirectToAction("success")); } else { IndexView viewindex = new IndexView() { AllMessages = _dbConnector.Messsages .Include(Message => Message.Creator) .Include(Message => Message.Likes).ThenInclude(users => users.Users) .ToList(), AllUsers = _dbConnector.Users.ToList() }; ViewBag.Name = HttpContext.Session.GetString("Name"); ViewBag.Alias = HttpContext.Session.GetString("Alias"); ViewBag.UserId = HttpContext.Session.GetInt32("UserId"); return(View("success", viewindex)); } }
public IActionResult AddBook(Book formBook) { if (ModelState.IsValid) { // find the author object to add to the book Author author = _context.Authors.SingleOrDefault(a => a.AuthorId == formBook.AuthorId); // Author author = _context.Authors.SingleOrDefault(a => a.AuthorId == 2); // set the book author field the the author instance formBook.Author = author; // add the book _context.Books.Add(formBook); // save the book _context.SaveChanges(); return(RedirectToAction("Index")); } else { // display the errors IndexView BookErrors = new IndexView() { FormBook = formBook, AllAuthors = _context.Authors.Include(author => author.Books).ToList(), AllBooks = _context.Books.Include(book => book.Author).Include(book => book.HasPublishers).ThenInclude(Publication => Publication.Publisher).ToList(), AllPublishers = _context.Publishers.Include(publisher => publisher.HasBooks).ThenInclude(publication => publication.Book).ToList() }; return(View("Index", BookErrors)); } }
public ActionResult Index(IndexView mode) { QPGameUserDB db = new QPGameUserDB(); if (!ModelState.IsValid) { return(View(mode)); } string pwd = Commom.Helpes.md5(mode.Password, 32); var dbset = db.AccountsInfo.Where(x => x.Accounts == mode.Account && x.LogonPass == pwd).FirstOrDefault(); if (dbset != null) { string CookieStr = Guid.NewGuid().ToString(); if (Request.Cookies["weigoldcook"] != null) { Response.Cookies["weigoldcook"].Expires = DateTime.Now.AddDays(-1); } HttpCookie cookie = new HttpCookie("weigoldcook"); cookie.Values.Add("uid", HttpUtility.UrlEncode(Commom.AES.getAesEncrypt(dbset.UserID.ToString()))); cookie.Values.Add("nickname", HttpUtility.UrlEncode(dbset.NickName)); Response.AppendCookie(cookie); } else { ModelState.AddModelError("Password", "账号或密码不正确"); return(View(mode)); } return(View()); }
public IActionResult CreateProduct(Product product) { if (ModelState.IsValid) { Product new_product = new Product() { product_id = product.product_id, product_name = product.product_name, product_description = product.product_description, product_quantity = product.product_quantity, product_image = product.product_image, }; _context.products.Add(new_product); // add new customer object to database _context.SaveChanges(); return(RedirectToAction("Product")); } IndexView model = new IndexView(); model.Product = new Product(); model.Product.product_name = product.product_name; model.Product.product_description = product.product_description; model.Product.product_quantity = product.product_quantity; return(View("NewProductForm", product)); }
public IActionResult Index() { var model = new IndexView(); model.Department = _departmentsService.GetDepartmentById(DepartmentId); model.Profile = _departmentProfileService.GetOrInitializeDepartmentProfile(DepartmentId); model.ImageUrl = $"{_appOptionsAccessor.Value.ResgridApiUrl}/api/v3/Avatars/Get?id={model.Profile.DepartmentId}&type=1"; var posts = _departmentProfileService.GetArticlesForDepartment(model.Profile.DepartmentProfileId); var visiblePosts = _departmentProfileService.GetVisibleArticlesForDepartment(model.Profile.DepartmentProfileId); if (visiblePosts != null && visiblePosts.Any()) { model.VisiblePosts = visiblePosts.Count; } if (posts.Any()) { model.Posts = posts.Skip(Math.Max(0, posts.Count() - 3)).ToList(); } else { model.Posts = new List <DepartmentProfileArticle>(); } return(View(model)); }
public IActionResult About(Author formAuthor) { ViewData["Message"] = "Your application description page."; if (ModelState.IsValid) { Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine($"author id is {formAuthor.Name}"); // add author _context.Authors.Add(formAuthor); _context.SaveChanges(); return(RedirectToAction("Index")); } else { // display the error messages IndexView AuthorErrors = new IndexView() { FormAuthor = formAuthor, AllAuthors = _context.Authors.Include(author => author.Books).ToList(), AllBooks = _context.Books.Include(book => book.Author).ToList() }; return(View("Index", AuthorErrors)); } // for delete // Author AuthorToChange = _context.Authors.FirstOrDefault(author => author.Name.Contains("Dave")); // _context.Authors.Remove(AuthorToChange); }
public IActionResult Order() { IndexView order_info = new IndexView(); order_info.Customers = _context.customers .Select(selector: customer => new SelectListItem() { Value = customer.customer_id.ToString(), Text = customer.customer_name }).ToList(); order_info.Products = _context.products .Select(selector: product => new SelectListItem() { Value = product.product_id.ToString(), Text = product.product_name }).ToList(); order_info.Order = new Order(); /* order_info._customer = _context.customers * .Include(customer => customer.customer_orders) * .ThenInclude(order => order.product_info) * .ToList();*/ order_info._order = _context.orders .Include(order => order.customer_info) .Include(order => order.product_info) .OrderByDescending(order => order.created_at) .ToList(); return(View(order_info)); }
public IActionResult SearchProducts(Product product_search) { List <Product> product_match = new List <Product>(); product_match = _context.products .Include(product => product.product_orders) .ThenInclude(order => order.customer_info) .Where(product => product.product_name == product_search.product_name).ToList(); if (product_match.Count == 0) { TempData["NoProductError"] = "No product in the Database"; IndexView model = new IndexView { _product = _context.products.OrderByDescending(product => product.created_at).Take(5).ToList(), _customer = _context.customers.OrderByDescending(customer => customer.created_at).Take(3).ToList(), _order = _context.orders .Include(order => order.customer_info) .Include(order => order.product_info) .OrderBy(order => order.created_at) .Take(3) .ToList() }; return(View("Product", model)); } return(View(product_match)); }
public IActionResult SearchCustomers(Customer customer_search) { List <Customer> customer_match = new List <Customer>(); customer_match = _context.customers .Include(customer => customer.customer_orders) .ThenInclude(order => order.product_info) .Where(customer => customer.customer_name == customer_search.customer_name).ToList(); if (customer_match.Count == 0) { TempData["NoCustomerError"] = "No customer in the Database"; IndexView model = new IndexView { _product = _context.products.OrderByDescending(product => product.created_at).Take(5).ToList(), _customer = _context.customers.OrderByDescending(customer => customer.created_at).Take(3).ToList(), _order = _context.orders .Include(order => order.customer_info) .Include(order => order.product_info) .OrderBy(order => order.created_at) .Take(3) .ToList() }; return(View("Index", model)); } return(View(customer_match)); }
public IActionResult Create(User user) { if (ModelState.IsValid) { string checkEmail = $"SELECT user_id FROM users WHERE email = '{user.email}'"; if (DbConnector.Query(checkEmail).Count > 0) { ModelState.AddModelError("email", "Email already in use"); } } if (ModelState.IsValid) { // Hash user's password for DB storage PasswordHasher <User> hasher = new PasswordHasher <User>(); string hashedPW = hasher.HashPassword(user, user.password); string createUser = $@"INSERT INTO users (first_name, last_name, email, password, created_at, updated_at) VALUES ('{user.first_name}', '{user.last_name}', '{user.email}', '{hashedPW}', NOW(), NOW());"; DbConnector.Execute(createUser); TempData["success"] = "You have successfully registered, you may now log in"; return(RedirectToAction("LoginView")); } IndexView idxModel = new IndexView() { Users = DbConnector.Query("SELECT * FROM users"), NewUser = user }; return(View("Index", idxModel)); }
public IActionResult Registration(User formUser) { if (formUser.password != formUser.ConfirmPass) { ModelState.AddModelError("Password", "Passwords need to match"); } if (_context.Users.Any(u => u.Email == formUser.Email)) { ModelState.AddModelError("Email", "Email already in use"); } if (ModelState.IsValid) { _context.Users.Add(formUser); _context.SaveChanges(); int uID = _context.Users.Last().userId; HttpContext.Session.SetInt32("UserID", uID); return(RedirectToAction("Success")); } else { IndexView RegErrors = new IndexView() { FormUser = formUser, AllUsers = _context.Users.ToList() }; Console.WriteLine("Invalid Form Sent"); Console.WriteLine(string.Join(',', ModelState)); return(View("index", RegErrors)); } }
public IActionResult Register(IndexView model) { //check databse if email already exists if (_context.users.Where(u => u.email == model.NewUser.email) .ToList() .Count() > 0) // or you can write ..... if(_context.user.SingleOrDefault(u => u.email == model.NewUser.email) != null) { ModelState.AddModelError("NewUser.email", "Email already exists"); } if (ModelState.IsValid) // No existing email was found. Create new User object and store incoming form info { User user = new User() { first_name = model.NewUser.first_name, last_name = model.NewUser.last_name, email = model.NewUser.email, password = model.NewUser.password, created_at = DateTime.Now, updated_at = DateTime.Now }; //hash plain text password PasswordHasher <User> hasher = new PasswordHasher <User>(); string hashed = hasher.HashPassword(user, user.password); user.password = hashed; _context.users.Add(user); _context.SaveChanges(); // the first registered user will be granted admin rights. Every other new // registred user will be considered a guest unless the 1st admin (or subsequent // admins) give them admin rights. The 1st admin will be able to give // a new registered user admin rights, or create/ and edit a new user w admin rights if (user.user_id == 16) //this line of code will only be used on the 1st registration { user.user_level = "Admin"; //changing user_level to admin } else { user.user_level = "Guest"; } _context.SaveChanges(); HttpContext.Session.SetInt32("id", (int)user.user_id); // this will determine rather the user is an admin or a guest if (user.user_level == "Admin") { return(RedirectToAction("Admin", "Dashboard")); } else { return(RedirectToAction("Guest", "Dashboard")); } } return(View("Index")); }
public IActionResult Index() { IndexView model = new IndexView(); model.Lists = _distributionListsService.GetDistributionListsByDepartmentId(DepartmentId); return(View(model)); }
public IndexView viewFunction() { IndexView stateAuctionResult = new IndexView(); stateAuctionResult.auctionList = GET_method().Results.ToList(); stateAuctionResult.state = (stateAuctionResult.auctionList.Select(s => s.PropertyState).Distinct()).OrderBy(s => s).ToList(); return(stateAuctionResult); }
public void SetController(PackageController controller) { IndexView.SetController(controller); CreateView.SetController(controller); EditView.SetController(controller); DetailView.SetController(controller); DeleteView.SetController(controller); }
public async Task <IActionResult> Index() { IndexView model = new IndexView(); model.Lists = await _distributionListsService.GetDistributionListsByDepartmentIdAsync(DepartmentId); return(View(model)); }
public IActionResult ShowUserInfo(int id) { IndexView model = new IndexView(); model.User = _context.users.SingleOrDefault(u => u.user_id == id); _context.SaveChanges(); return(View(model)); }
public static Quotas Initialize(File file) { Index ownerIndex = file.CreateIndex("$O", (AttributeType)0, AttributeCollationRule.Sid); Index quotaIndox = file.CreateIndex("$Q", (AttributeType)0, AttributeCollationRule.UnsignedLong); IndexView<OwnerKey, OwnerRecord> ownerIndexView = new IndexView<OwnerKey, OwnerRecord>(ownerIndex); IndexView<OwnerRecord, QuotaRecord> quotaIndexView = new IndexView<OwnerRecord, QuotaRecord>(quotaIndox); OwnerKey adminSid = new OwnerKey(new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null)); OwnerRecord adminOwnerId = new OwnerRecord(256); ownerIndexView[adminSid] = adminOwnerId; quotaIndexView[new OwnerRecord(1)] = new QuotaRecord(null); quotaIndexView[adminOwnerId] = new QuotaRecord(adminSid.Sid); return new Quotas(file); }
public ObjectIds(File file) { _file = file; _index = new IndexView<IndexKey, ObjectIdRecord>(file.GetIndex("$O")); }
private void VerifyDirectories() { foreach (FileRecord fr in _context.Mft.Records) { if (fr.BaseFile.Value != 0) { continue; } File f = new File(_context, fr); foreach (var stream in f.AllStreams) { if (stream.AttributeType == AttributeType.IndexRoot && stream.Name == "$I30") { IndexView<FileNameRecord, FileRecordReference> dir = new IndexView<FileNameRecord, FileRecordReference>(f.GetIndex("$I30")); foreach (var entry in dir.Entries) { FileRecord refFile = _context.Mft.GetRecord(entry.Value); // Make sure each referenced file actually exists... if (refFile == null) { ReportError("Directory {0} references non-existent file {1}", f, entry.Key); } File referencedFile = new File(_context, refFile); StandardInformation si = referencedFile.StandardInformation; if (si.CreationTime != entry.Key.CreationTime || si.MftChangedTime != entry.Key.MftChangedTime || si.ModificationTime != entry.Key.ModificationTime) { ReportInfo("Directory entry {0} in {1} is out of date", entry.Key, f); } } } } } }
public Quotas(File file) { _ownerIndex = new IndexView<OwnerKey, OwnerRecord>(file.GetIndex("$O")); _quotaIndex = new IndexView<OwnerRecord, QuotaRecord>(file.GetIndex("$Q")); }
public ReparsePoints(File file) { _file = file; _index = new IndexView<Key, Data>(file.GetIndex("$R")); }