public ActionResult Post(LocationFeedbackDto locationFeedback) { if (ModelState.IsValid) { _repository.Add(locationFeedback); ModelState.Clear(); return(RedirectToAction("ShowFeedback", new { id = locationFeedback.LocationId })); } return(View(locationFeedback)); }
public ActionResult PostDrinkType(DrinkType drink) { if (ModelState.IsValid) { _typeService.Add(drink); ModelState.Clear(); return(View()); } return(View(drink)); }
public ActionResult Post(LocationFormDto location) { if (ModelState.IsValid) { _repository.Add(location); ModelState.Clear(); ViewBag.Message = "Success!"; return(View()); } return(View(location)); }
public CommonResult Add(DrinkDto item) { if (string.IsNullOrEmpty(item.Name)) { return(CommonResult.Failure("No Name is declared")); } if (item.Price <= 0) { return(CommonResult.Failure("Price is not declared or less or equal then zero!")); } if (item.DrinkTypeId <= 0 || item.LocationOfDrinkId <= 0) { return(CommonResult.Failure("Wrong data with dropdown element")); } _repository.Add(item); return(CommonResult.Success()); }
public async Task <IActionResult> CreateRestaurant(int hotelId, RestaurantForUpdateDto restaurantForUpdateDto) { if (restaurantForUpdateDto == null) { return(BadRequest()); } var restaurantEntity = _mapper.Map <Restaurant>(restaurantForUpdateDto); restaurantEntity.HotelId = hotelId; _repo.Add(restaurantEntity); if (await _unitOfWork.CompleteAsync()) { var restaurantToReturn = _mapper.Map <RestaurantForUpdateDto>(restaurantEntity); return(CreatedAtRoute("GetRestaurant", new { id = restaurantEntity.Id }, restaurantToReturn)); } throw new Exception("Creating the restaurant failed on save"); }
public async Task <IActionResult> CreateOpenHours(int hotelId, OpenHourForUpdateDto openHourForUpdateDto) { if (openHourForUpdateDto == null) { return(BadRequest()); } var openHourEntity = _mapper.Map <OpenTime>(openHourForUpdateDto); openHourEntity.HotelId = hotelId; _repo.Add(openHourEntity); if (await _unitOfWork.CompleteAsync()) { var openHourToReturn = _mapper.Map <OpenHourForUpdateDto>(openHourEntity); return(CreatedAtRoute("GetOpenHour", new { id = openHourToReturn.Id }, openHourToReturn)); } throw new Exception("Creating the open hours failed on save"); }