コード例 #1
0
ファイル: EntriesController.cs プロジェクト: PJMPR/Westeros
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Weight,UserProfileId")] Entry entry)
        {
            if (id != entry.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(entry);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EntryExists(entry.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(entry));
        }
コード例 #2
0
ファイル: RecipeController.cs プロジェクト: PJMPR/Westeros
 public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Cuisine,Desription,PrepTime,Difficulty")] Data.Recipe recipe)
 {
     if (HttpContext.Session.GetInt32("Id") == null)
     {
         return(RedirectToAction(nameof(UserProfileController.SignIn)));
     }
     else
     {
         if (id != recipe.Id)
         {
             return(NotFound());
         }
         if (ModelState.IsValid)
         {
             try
             {
                 _context.Update(recipe);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!RecipeExists(recipe.Id))
                 {
                     return(NotFound());
                 }
                 throw;
             }
             return(RedirectToAction(nameof(IndexAsync)));
         }
         return(View(recipe));
     }
 }
コード例 #3
0
        public async Task <IActionResult> Index(int id, [Bind("Id, Name, LastName, Login, Email, ConfirmEmail, Sex, Age, Weight, Height")] UserProfileModel userProfile)
        {
            if (id != userProfile.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var up = modelToContext(userProfile);

                _context.Update(up);
                await _context.SaveChangesAsync();


                return(RedirectToAction("Index"));
            }
            return(View(userProfile));
        }