예제 #1
0
        public async Task <IActionResult> UpdateDinnerAsync(int id, [FromBody] Dinner dinner)
        {
            if (dinner.DinnerId != id)
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
            }

            var user = await _userManager.FindByIdAsync(Context.User.GetUserId());

            if (!dinner.IsUserHost(user.UserName))
            {
                return(HttpNotFound());
            }

            GeoLocation.SearchByPlaceNameOrZip(dinner);
            dinner = await _repository.UpdateDinnerAsync(dinner);

            return(new ObjectResult(dinner));
        }
        public async Task <IActionResult> UpdateDinner(int id, Dinner dinner)
        {
            if (ModelState.IsValid)
            {
                Dinner dinner1 = await _repository.GetDinnerAsync(id);

                dinner1.Address      = dinner.Address;
                dinner1.EventDate    = dinner.EventDate;
                dinner1.Title        = dinner.Title;
                dinner1.Description  = dinner.Description;
                dinner1.ContactPhone = dinner.ContactPhone;
                dinner1.Latitude     = dinner.Latitude;
                dinner1.Longitude    = dinner.Longitude;
                await _repository.UpdateDinnerAsync(dinner1);

                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Error", "Home"));
        }
예제 #3
0
        public async Task <IActionResult> UpdateDinnerAsync(int id, [FromBody] Dinner dinner)
        {
            if (dinner.DinnerId != id)
            {
                return(View("Error"));
            }

            var user = HttpContext.User;

            if (!dinner.IsUserHost(user.Identity.Name))
            {
                return(View("Error"));
            }

            GeoLocation.SearchByPlaceNameOrZip(dinner);
            dinner = await _repository.UpdateDinnerAsync(dinner);

            return(new ObjectResult(dinner));
        }
예제 #4
0
        public async Task <IActionResult> UpdateDinnerAsync(int id, [FromBody] Dinner dinner)
        {
            if (ModelState.IsValid)
            {
                if (dinner.DinnerId != id)
                {
                    return(BadRequest());
                }
                if (!dinner.IsUserHost(User.Identity.Name))
                {
                    return(BadRequest());
                }

                GeoLocation.SearchByPlaceNameOrZip(dinner);
                dinner = await _repository.UpdateDinnerAsync(dinner);

                return(new ObjectResult(dinner));
            }
            return(BadRequest());
        }