public async Task <IActionResult> PutTuner([FromRoute] string id, [FromBody] Tuner tuner)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tuner.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tuner).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TunerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
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());
        }
예제 #3
0
        public async void Delete(Movie entity)
        {
            var user = await _context.Movies.SingleOrDefaultAsync(u => u.Id == entity.Id);

            _context.Movies.Remove(user);
            await _context.SaveChangesAsync();
        }
예제 #4
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));
        }
예제 #5
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));
        }
예제 #6
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));
        }
예제 #7
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));
        }
예제 #8
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));
        }
예제 #9
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));
        }
예제 #10
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));
        }
        public async Task <ActionResult> Create([Bind(Include = "id,item,price,qty")] RestaurantMenu restaurantMenu)
        {
            if (ModelState.IsValid)
            {
                db.RestaurantMenus.Add(restaurantMenu);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(restaurantMenu));
        }
예제 #12
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));
        }
예제 #13
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);
        }
        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));
        }
예제 #15
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));
        }
예제 #16
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());
        }
예제 #17
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 })));
        }