コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("StartDate,EndDate,Id")] Repertoire repertoire)
        {
            if (id != repertoire.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(repertoire);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RepertoireExists(repertoire.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(repertoire));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id")] FunZone funZone)
        {
            if (id != funZone.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(funZone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FunZoneExists(funZone.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(funZone));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Duration,Name,Description,ProjectionTypeString,Id")] Projection projection)
        {
            if (id != projection.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(projection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectionExists(projection.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(projection));
        }
コード例 #4
0
ファイル: BidsController.cs プロジェクト: lukakovac/ISA
        public async Task <IActionResult> Create([Bind("Price,Id")] Bid bid, int thematicPropId)
        {
            if (ModelState.IsValid)
            {
                var appUser = await _userManager.GetUserAsync(HttpContext.User);

                var prop = _context.ThematicProps.SingleOrDefault(x => x.Id == thematicPropId);
                bid.ThematicPropId = prop.Id;
                bid.User           = _context.UserProfiles.SingleOrDefault(x => x.Id == appUser.UserProfileId);
                if (prop.Price < bid.Price)
                {
                    prop.Price = bid.Price;
                }

                _context.Add(bid);
                _context.Update(prop);
                await _context.SaveChangesAsync();

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