示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Effort,AdvertisementId")] ProfitAdv profitAdv)
        {
            if (ModelState.IsValid)
            {
                _context.Add(profitAdv);
                if (profitAdv.Effort > 0 && profitAdv.Effort <= 4000)
                {
                    profitAdv.kef = 2;
                }
                else if (profitAdv.Effort > 4000 && profitAdv.Effort <= 10000)
                {
                    profitAdv.kef = 5;
                }
                else if (profitAdv.Effort > 10000 && profitAdv.Effort <= 50000)
                {
                    profitAdv.kef = 11;
                }
                else
                {
                    profitAdv.kef = 18;
                }
                profitAdv.Profit = (int)(profitAdv.Effort + (profitAdv.kef * profitAdv.Effort / 9));
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }


            ViewData["AdvertisementId"] = new SelectList(_context.Advertisements, "AdvertisementId", "Company", profitAdv.AdvertisementId);
            return(View(profitAdv));
        }
        public async Task <IActionResult> Create([Bind("AdvertisementId,Company,Text")] Advertisement advertisement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(advertisement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(advertisement));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,Email,Password,RoleId")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"] = new SelectList(_context.Roles, "Id", "Id", user.RoleId);
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,Mark,AdvertisementId,UserId")] AdvMark advMark)
        {
            if (ModelState.IsValid)
            {
                _context.Add(advMark);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdvertisementId"] = new SelectList(_context.Advertisements, "AdvertisementId", "Company", advMark.AdvertisementId);
            ViewData["UserId"]          = new SelectList(_context.Users, "Id", "Email", advMark.UserId);
            return(View(advMark));
        }