예제 #1
0
        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
        public async Task <IActionResult> Create([Bind("Id,Name,Cuisine,Desription,PrepTime,Difficulty")] Data.Recipe recipe)
        {
            if (HttpContext.Session.GetInt32("Id") == null)
            {
                return(RedirectToAction(nameof(UserProfileController.SignIn)));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    _context.Add(recipe);
                    await _context.SaveChangesAsync();

                    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));
        }