Exemple #1
0
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var climate = climateRepository.GetSingleClimate(id ?? (int)InvalidPropertyValues.undefinedValue);

            if (climate == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ClimateFormViewModel(climate);

            return(View("ClimateForm", viewModel));
        }
        public IHttpActionResult DeleteClimate(int?id)
        {
            if (!id.HasValue)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var climateDb = climateRepository.GetSingleClimate(id ?? (int)InvalidPropertyValues.undefinedValue);

            if (climateDb == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            climateRepository.Remove(climateDb);

            unitOfWork.Complete();

            return(Ok());
        }