Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,ProjectId,Name,Description,Value")] Package package)
        {
            if (ModelState.IsValid)
            {
                _context.Add(package);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", new { id = package.ProjectId }));
                // return RedirectToAction( "Index", new RouteValueDictionary(
                // new { controller = "PackagesPrjct", action = "Index",  @id = id  } ) );
                //return RedirectToPage()
            }
            string useridd = HttpContext.User.Identity.Name;
            var    userid  = (from m in _context.AspNetUsers
                              where m.Email == useridd
                              select m.Id)
                             .FirstOrDefault();

            var prjcts = (from m in _context.Project
                          //join sem in _context.Project on m.ProjectId  equals sem.Id
                          where m.PersonId == userid
                          select new { m.Title, m.Id }).Distinct();

            //ViewData["ProjectId"] = new SelectList(prjcts);
            ViewData["ProjectId"] = new SelectList(prjcts, "Id", "Title", package.ProjectId);

            return(View());
        }
Exemplo n.º 2
0
 public static void AddUser(User user)
 {
     using (var db = new FinalProjectContext())
     {
         db.Add(user);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("SoftwareID,Name,Version,URL,CSOnly")] Software software)
        {
            if (ModelState.IsValid)
            {
                _context.Add(software);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(software));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Major,ID,FirstName,LastName,Email,Phone")] Member member)
        {
            if (ModelState.IsValid)
            {
                _context.Add(member);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("ProfessorID,Name,Email,PhoneNumber")] Professor professor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(professor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(professor));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ID,ProjectName,ProjectDescription")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("CompanyName,ID,FirstName,LastName,Email,Phone")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("CSSystemID,Name,IPAddress,PrimaryUserID")] CSSystem cSSystem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cSSystem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PrimaryUserID"] = new SelectList(_context.Professors, "ProfessorID", "ProfessorID", cSSystem.PrimaryUserID);
            return(View(cSSystem));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Id,PersonId,CategoryId,HeroUrl,Title,Description,Deadline,Goal")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Title", project.CategoryId);
            ViewData["PersonId"]   = new SelectList(_context.AspNetUsers, "Id", "Id", project.PersonId);
            return(View(project));
        }
Exemplo n.º 11
0
        public IActionResult Add([Bind("Id,Company,Position,Contact,Method,DateOfApplication,Link,FollowUp,CompanySite,Responded,Notes,UserId")] Job job)
        {
            if (ModelState.IsValid)
            {
                // Ensuring job.UserId is set to the UserId of logged in user
                job.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

                job.FollowUp = DateTime.Now.AddDays(2);

                // Add job and save changes in database
                _context.Add(job);
                _context.SaveChanges();

                // Storing action name in TempData to customize Success page
                TempData["action"] = "add";
                return(RedirectToAction("Success", job));
            }
            return(View(job));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("Id,ProjectId,Name,Description,Value")] Package package)
        {
            if (ModelState.IsValid)
            {
                _context.Add(package);
                await _context.SaveChangesAsync();

                //return RedirectUrl(nameof(Index));
                //return RedirectToAction("Index");
                //var request = HttpContext.Request;
                //var referrer = request.UrlReferrer;
                //return Redirect(Request.UrlReferrer.ToString());
                //RedirectToRoute("~/PackagesPrjct/Index", new { id = package.Id });
                return(RedirectToAction("Index", new { id = package.ProjectId }));
                //return RedirectToAction(nameof(Index),package.Id);
                //Response.Redirect(Request.UrlReferrer.AbsoluteUri.ToString());
                //return RedirectToAction("Create",
                //new { returnUrl = Request.UrlReferrer.ToString() });
            }

            string useridd = HttpContext.User.Identity.Name;
            var    userid  = (from m in _context.AspNetUsers
                              where m.Email == useridd
                              select m.Id)
                             .FirstOrDefault();

            var prjcts = (from m in _context.Project
                          //join sem in _context.Package on m.Id equals sem.ProjectId
                          where m.PersonId == userid
                          select new { m.Title, m.Id }).Distinct();

            // ViewData["ProjectId"] = new SelectList(_context.Project, "Id", "Description");


            ViewData["ProjectId"] = new SelectList(prjcts, "Id", "Title", package.ProjectId);

            return(View());
            //ViewData["ProjectId"] = new SelectList(prjcts);
            //ViewData["ProjectId"] = new SelectList(_context.Project, "Id", "Title", package.ProjectId);

            //return View(package);
        }
Exemplo n.º 13
0
        public static void AddDrug(Drug drug, int userId)
        {
            using (var db = new FinalProjectContext())
            {
                var users = db.Users.
                            Where(x => (x.UserId == userId));
                List <User> users__ = new List <User>();
                foreach (User x in users)
                {
                    users__.Add(x);
                }
                User user = users__.ElementAt(0);

                drug.Time = DateTime.Now;
                drug.User = user;

                db.Add(drug);
                db.SaveChanges();
            }
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("Id,PersonId,CategoryId,HeroUrl,Title,Description,Deadline,Goal")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { id = project.Id }));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Title", project.CategoryId);

            string useridd = HttpContext.User.Identity.Name;

            var userid = from m in _context.AspNetUsers
                         where m.Email == useridd
                         select m.Id;

            //ViewData["PersonId"] = new SelectList(_context.AspNetUsers, "Id", "Id", project.PersonId);
            ViewData["PersonId"] = new SelectList(userid);
            return(View(project));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("Username,Pword,Amount")] Users users) //need to insert Stock purchase entry for this user
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(users);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Create", new RouteValueDictionary(
                                                new { controller = "StockPurchaseEntry", action = "Create", id = users.Id })));
                }
                catch (DbUpdateException)
                {
                    return(StatusCode(409));
                }
            }


            return(View());
        }
        public async Task <IActionResult> Create([Bind("InventoryItemID,Description,UserID")] InventoryItem inventoryItem)
        {
            if (ModelState.IsValid)
            {
                //Automatically marking item checked out status based on if there was a UserID passed or not
                if (inventoryItem.UserID != null)
                {
                    inventoryItem.CheckedOut = true;
                }
                else
                {
                    inventoryItem.CheckedOut = false;
                }
                _context.Add(inventoryItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"] = new SelectList(_context.Professors, "ProfessorID", "ProfessorID", inventoryItem.UserID);
            return(View(inventoryItem));
        }
Exemplo n.º 17
0
 public async void Insert(Movie entity)
 {
     _context.Add(entity);
     await _context.SaveChangesAsync();
 }
Exemplo n.º 18
0
        //called to send data after user has updated the chart
        public async Task updateUserData(string socketId, string newShares1, string newShares2, string newShares3, string symbol, string symbol2, string symbol3)
        {
            UsersController dbRead = new UsersController(context: _context);


            var user = await _context.Users.SingleOrDefaultAsync(x => x.Id == ApiDataCalls.curId);


            StockPurchaseEntry UserEntry = new StockPurchaseEntry();

            UserEntry.UsersId = ApiDataCalls.curId;

            for (int i = 1; i <= 3; i++)
            {
                if (i == 1)
                {
                    UserEntry.UsersId          = ApiDataCalls.curId;
                    UserEntry.Company_Name     = symbol;
                    UserEntry.Purchased_Amount = Convert.ToInt32(newShares1);
                    UserEntry.Amount_Paid      = 0;

                    _context.Add(UserEntry);
                    await _context.SaveChangesAsync();

                    // _context.SaveChanges();
                }
                else if (i == 2)
                {
                    UserEntry.UsersId          = ApiDataCalls.curId;
                    UserEntry.Company_Name     = symbol;
                    UserEntry.Purchased_Amount = Convert.ToInt32(newShares1);
                    UserEntry.Amount_Paid      = 0;

                    _context.Add(UserEntry);
                    //_context.SaveChanges();
                    await _context.SaveChangesAsync();
                }
                else if (i == 3)
                {
                    UserEntry.UsersId          = ApiDataCalls.curId;
                    UserEntry.Company_Name     = symbol;
                    UserEntry.Purchased_Amount = Convert.ToInt32(newShares1);
                    UserEntry.Amount_Paid      = 0;

                    _context.Add(UserEntry);
                    //_context.SaveChanges();
                    await _context.SaveChangesAsync();
                }
            }

            List <StockPurchaseEntry> list = new List <StockPurchaseEntry>();

            foreach (StockPurchaseEntry entry in ApiDataCalls.itemsToPass)
            {
                entry.Users = null;

                list.Add(entry);
            }

            var rawData = JsonConvert.SerializeObject(list);

            await InvokeClientMethodToAllAsync("ParseValueAndCreateTable", socketId, rawData);
        }
        public async Task <IActionResult> Create([Bind("UsersId,stock1,stock2,stock3")]
                                                 Stocks stock)
        {
            StockPurchaseEntry UserEntry = new StockPurchaseEntry();

            UserEntry.UsersId = stock.UsersId;
            for (int i = 1; i <= 3; i++)
            {
                if (i == 1)
                {
                    UserEntry.Company_Name     = stock.stock1;
                    UserEntry.Purchased_Amount = stocksPurchased(UserEntry.Company_Name, UserEntry.UsersId);
                    UserEntry.Amount_Paid      = intitialBalance(UserEntry.UsersId);

                    _context.Add(UserEntry);
                    await _context.SaveChangesAsync();

                    // _context.SaveChanges();
                }
                else if (i == 2)
                {
                    UserEntry                  = new StockPurchaseEntry();
                    UserEntry.UsersId          = stock.UsersId;
                    UserEntry.Company_Name     = stock.stock2;
                    UserEntry.Purchased_Amount = stocksPurchased(UserEntry.Company_Name, UserEntry.UsersId);
                    UserEntry.Amount_Paid      = intitialBalance(UserEntry.UsersId);

                    _context.Add(UserEntry);
                    //_context.SaveChanges();
                    await _context.SaveChangesAsync();
                }
                else if (i == 3)
                {
                    UserEntry                  = new StockPurchaseEntry();
                    UserEntry.UsersId          = stock.UsersId;
                    UserEntry.Company_Name     = stock.stock3;
                    UserEntry.Purchased_Amount = stocksPurchased(UserEntry.Company_Name, UserEntry.UsersId);
                    UserEntry.Amount_Paid      = intitialBalance(UserEntry.UsersId);

                    _context.Add(UserEntry);
                    //_context.SaveChanges();
                    await _context.SaveChangesAsync();
                }
            }

            /*[Bind("UsersId,Company_Name,Purchased_Amount,Amount_Paid")]
             * StockPurchaseEntry stockPurchaseEntry
             * /*
             * if (ModelState.IsValid)
             * {
             *  _context.Add(stockPurchaseEntry);
             *  await _context.SaveChangesAsync();
             *  return RedirectToAction(nameof(Index));
             * }
             * ViewData["UsersId"] = new SelectList(_context.Users, "Id", "Id", stockPurchaseEntry.UsersId);*/

            Console.WriteLine("This is the User " + stock.UsersId + "Stock 1:" + stock.stock1 + "Stock 2:" + stock.stock2 + "Stock 3:" + stock.stock3);
            //await _context.SaveChangesAsync();
            var user = _context.Users.First(x => x.Id == stock.UsersId);

            return(RedirectToAction("Details", new RouteValueDictionary(
                                        new { controller = "Users", action = "Details", user.Username, user.Pword })));
        }
Exemplo n.º 20
0
 public async void Insert(Category entity)
 {
     _context.Add(entity);
     await _context.SaveChangesAsync();
 }