public IActionResult AddRestaurant([FromBody] AddRestaurantRequest restaurant) { addRestaurantRequestValidator.ValidateAndThrow(restaurant); var addRestaurant = restaurantRepository.AddRestaurant(restaurant); return(Ok(addRestaurant)); }
public void AddRestaurant(AddRestaurantRequest request) { var company = new Restaurant(); if (!string.IsNullOrEmpty(request.Guid)) { company = restaurantRepository.FindAll(x => x.Guid == request.Guid).FirstOrDefault(); } else { company.Guid = Guid.NewGuid().ToString(); } company.Name = request.Name; company.Description = request.Description; company.Logo = request.Logo; restaurantRepository.Add(company); var location = locationRepository.FindAll(x => x.OwnerGuid == company.Guid).FirstOrDefault(); if (location == null) { location = new Location(); } location.Address = request.Address; location.Lattitude = request.Lat; location.Longitude = request.Lng; location.OwnerGuid = company.Guid; location.Type = LocationType.Restaurant; locationRepository.Add(location); }
public long AddRestaurant(AddRestaurantRequest addRestaurant) { var restaurant = mapper.Map <Restaurants>(addRestaurant); context.Add(restaurant); context.SaveChanges(); return(restaurant.Id); }
public IActionResult AddRestaurant([FromBody] AddRestaurantRequest request) { if (string.IsNullOrEmpty(request.Name) || string.IsNullOrEmpty(request.Description)) { throw new Exception("Lütfen alanları doldurunuz."); } var response = serviceProcessor.Call(restaurantService.AddRestaurant, request); return(Json(response)); }
public async Task <BaseResponse> AddAsync(AddRestaurantRequest request) { var restaurant = _mapper.Map <AddRestaurantRequest, Restaurant>(request); var loggedUser = (User)_httpContext.Items.GetOrDefault("User"); restaurant.CreatedById = loggedUser.Id; await _restaurantRepository.AddAsync(restaurant); await _unitOfWork.SaveChangesAsync(); return(new BaseResponse()); }
public async Task <IActionResult> Add([FromBody] AddRestaurantRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var response = await _restaurantService.AddAsync(request); if (!response.IsValid) { return(BadRequest(response.Message)); } return(Ok(response)); }
public async Task <bool> Handle(AddRestaurantRequest request, IOutputPort <AddRestaurantResponse> outputPort) { bool created = await _restaurantRepository.Insert(new Restaurant { Id = request.Id, Name = request.Name, Address = request.Address, City = request.City, PostalCode = request.PostalCode, Location = request.Location, Phone = request.Phone, Categories = request.Categories, Rating = request.Rating, Url = request.Url, CoverUrl = request.Url }); outputPort.Handle(created ? new AddRestaurantResponse(true, string.Empty) : new AddRestaurantResponse(false, string.Empty)); return(created); }