示例#1
0
        public ActionResult <BaseViewModel <LocationViewModel> > PostLocation(CreateLocationRequestViewModel location)
        {
            var result = _locationService.CreateLocation(location);

            this.HttpContext.Response.StatusCode = (int)result.StatusCode;

            return(result);
        }
        public HttpResponseMessage CreateLocation([FromBody] LocationDTO locationDTO)
        {
            int    newID    = _locationService.CreateLocation(locationDTO);
            string uri      = Url.Link("LocationByIDRoute", new { id = newID });
            var    response = new HttpResponseMessage(HttpStatusCode.Created);

            response.Headers.Location = new System.Uri(uri);
            return(response);
        }
        public IActionResult Post([FromBody] CreateLocationModel createModel)
        {
            var      createLocationCommand = _mapper.Map <CreateLocationModel, CreateLocationCommand>(createModel);
            Location location = _locationService.CreateLocation(createLocationCommand);

            var model = _mapper.Map <Location, LocationModel>(location);

            return(CreatedAtRoute("GetLocationById", new { id = location.LocationId }, model));
        }
示例#4
0
        public async Task <IActionResult> CreateLocation([FromBody] SaveLocationModel saveLocationModel)
        {
            string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            return(Ok(await _locationService.CreateLocation(saveLocationModel, userId)));
        }
        public IActionResult Create(LocationViewModel location)
        {
            var checkcreateLocation = _locationService.CreateLocation(_mapper.Map <LocationSharedModel>(location));

            if (!checkcreateLocation)
            {
                ViewBag.Message = "Địa chỉ đã có trong Database";
            }
            return(RedirectToAction("Index"));
        }
        public IActionResult Post([FromBody] CreateLocationModel createModel)
        {
            var createLocationCommand = _mapper.Map <CreateLocationModel, CreateLocationCommand>(createModel);
            var result = _locationService.CreateLocation(createLocationCommand);

            return(CreateResponse <Location, LocationModel>(result, (entity) => {
                var model = _mapper.Map <Location, LocationModel>(entity);
                return CreatedAtRoute("GetLocationById", new { id = entity.LocationId }, model);
            }));
        }
示例#7
0
        public async Task <ActionResult <LocationViewModel> > Post([FromBody] LocationViewModel locationModel)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity(ModelState));
            }

            var location = await _locationService.CreateLocation(Mapper.Map <Location>(locationModel));

            return(Ok(Mapper.Map <LocationViewModel>(location)));
        }
 public IActionResult CreateLoc(Location newLoc)
 {
     try
     {
         return(Ok(_locationService.CreateLocation(newLoc)));
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
示例#9
0
        public IActionResult Create([FromForm] Location location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            locationService.CreateLocation(location);

            return(Redirect(Url.Action("AllLocations", "Locations")));
        }
示例#10
0
        public async Task <IActionResult> CreateLocation(CreateLocationDTO input)
        {
            try
            {
                await _locationService.CreateLocation(input);

                return(Ok("The process is success"));
            }
            catch (Exception)
            {
                return(BadRequest("An error occurred during the creating process. Please try again !"));
            }
        }
示例#11
0
 public ActionResult Create(Location newLocation)
 {
     if (ModelState.IsValid)
     {
         newLocation.isDelete = false;
         //Mapping to domain
         //Create Blog
         _LocationService.CreateLocation(newLocation);
         return(RedirectToAction("Index", "Location"));
     }
     else
     {
         return(View("Create", newLocation));
     }
 }
        // [Authorize(Roles = Role.Admin)]
        public IActionResult CreateLocation([FromBody] LocationRequest locationRequest)
        {
            if (locationRequest.Name == null || locationRequest.Position == null || locationRequest.Orientation == null)
            {
                return(GetResultBadRequest());
            }

            try
            {
                _locationService.CreateLocation(locationRequest);
                return(GetResultCreated());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(GetResultInternalError());
            }
        }
        public async Task <ActionResult> CreateLocation([FromBody] LocationCreateDTO newLocation)
        {
            try
            {
                if (!await _editRightsService.HasEditRights(newLocation.TripId))
                {
                    return(BadRequest(new JsonResult("You can't currently edit this trip.")));
                }
                LocationDTO result = await _locationService.CreateLocation(newLocation);

                await _editRightsService.ProlongEditRights(newLocation.TripId, _redisAppSettings.EditRightsProlongedTTL);

                if (result != null)
                {
                    return(Ok(result));
                }
                return(BadRequest(new JsonResult("Location dates are not valid")));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#14
0
        public async Task <IActionResult> Create([FromBody] LocationDto model)
        {
            var currentUser = await _identityService.GetCurrentUser();

            if (currentUser == null)
            {
                return(BadRequest(new { error = "You are not allowed!" }));
            }

            var person = await _identityService.GetPersonByUserId(currentUser.Id);

            if (person == null)
            {
                return(BadRequest(new { error = "Person was not found" }));
            }

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            if (model == null)
            {
                return(NotFound());
            }

            var location = new Location()
            {
                Name    = model.Name,
                Address = model.Address
            };

            await _locationService.CreateLocation(location);

            return(Ok());
        }
        public async Task <IActionResult> Create(CreateLocationViewModel input)
        {
            try
            {
                string url = await _blobManager.UploadImageAsBlob(input.Photo);

                CreateLocationDTO data = new CreateLocationDTO()
                {
                    Name      = input.Name,
                    PhotoURL  = url,
                    ProjectId = input.ProjectId,
                    Latitude  = input.Latitude,
                    Longitude = input.Longitude,
                    UserId    = input.UserId
                };
                await _locationService.CreateLocation(data);

                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
示例#16
0
 public void Post(LocationViewModel location)
 {
     _locationService.CreateLocation(location);
 }
示例#17
0
        public async Task <IActionResult> PostLocation(Location location)
        {
            var newService = await locationService.CreateLocation(location.Name, location.PricePerMinute);

            return(Created($"/api/catalogs/{newService.Id}", newService));
        }
        public IActionResult CreateLocation([FromBody] LocationCreateDto model)
        {
            var result = _services.CreateLocation(model);

            return(CreatedAtRoute(nameof(GetLocationById), new { Id = result.LocationId }, result));
        }