Пример #1
0
        public IActionResult CreateLocation(LocationCreate location)
        {
            if (WarehouseService.CreateLocation(location, UserID))
            {
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
Пример #2
0
        public bool CreateLocation(LocationCreate locationToCreate)
        {
            var entity = new Location
            {
                Name = locationToCreate.Name
            };

            _db.Locations.Add(entity);
            return(_db.SaveChanges() == 1);
        }
Пример #3
0
        public IActionResult Create(string applicationUserId)
        {
            var model = new LocationCreate();

            if (applicationUserId != null)
            {
                model.ApplicationUserId = applicationUserId;
            }
            return(View(model));
        }
Пример #4
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity = new Location()
            {
                Name        = model.Name,
                Description = model.Description
            };

            ctx.Locations.Add(entity);
            return(ctx.SaveChanges() == 1);
        }
 public ActionResult Create(LocationCreate model)
 {
     if (ModelState.IsValid)
     {
         var service = new LocationService(Guid.Parse(User.Identity.GetUserId()));
         var result  = service.CreateLocation(model);
         TempData["SaveResult"] = "New location successfully created.";
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Пример #6
0
        public ActionResult Create(LocationCreate location)
        {
            if (ModelState.IsValid)
            {
                _userId          = Guid.Parse(User.Identity.GetUserId());
                _locationService = new LocationService(_userId);
                _locationService.CreateLocation(location);
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
Пример #7
0
 public IActionResult LocationCreate([FromBody] LocationCreate dto)
 {
     try
     {
         _storage.LocationCreateUpdate(dto.EarTag, dto.Latitude, dto.Longitude);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
Пример #8
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity = new Location()
            {
                OwnerId         = _userId,
                TaggingLocation = model.TaggingLocation
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Location.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #9
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity = new Location()
            {
                LocationName = model.LocationName,
                AdventureId  = model.AdventureId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #10
0
        public IHttpActionResult Post(LocationCreate location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (!_locationService.CreateLocation(location))
            {
                return(InternalServerError());
            }

            return(Ok("The location was successfully created"));
        }
Пример #11
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                LocationState = model.LocationState,
                LocationCity  = model.LocationCity,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #12
0
        public IHttpActionResult PostLocation([FromBody] LocationCreate location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = new LocationService();

            if (!service.CreateLocation(location))
            {
                return(InternalServerError());
            }

            return(Ok("Location successfully added."));
        }
Пример #13
0
        public bool CreateLocation(LocationCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = new Location()
                {
                    LocationId = model.LocationId,
                    City       = model.City,
                    State      = model.State,
                    Park       = model.Park
                };

                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #14
0
    { //___________________Post-Create____________
        public bool CreateLocation(LocationCreate model)
        {
            var entity = new Location()
            {
                Kind  = model.Kind,
                Size  = model.Size,
                Color = model.Color,
                Place = model.Place
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #15
0
        public IHttpActionResult Post(LocationCreate locationToCreate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateLocationService();

            if (!service.CreateLocation(locationToCreate))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Пример #16
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                OwnerID      = _userId,
                LocationName = model.LocationName,
                ZipCode      = model.ZipCode
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #17
0
        public ActionResult Create(LocationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (CreateLocationService().CreateLocation(model))
            {
                TempData["SaveResult"] = "Location established";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Error creating Location");
            return(View(model));
        }
Пример #18
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                Continent       = model.Continent,
                Country         = model.Country,
                State_Territory = model.State_Territory,
                City            = model.City
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #19
0
        public bool CreateLocation(LocationCreate model)
        {
            UserProfile userProfile = _db.UserProfiles.Single(up => up.OwnerId == _userId);
            Location    location    = new Location()
            {
                OwnerId       = _userId,
                Title         = model.Title,
                Description   = model.Description,
                StreetAddress = model.StreetAddress,
                // TimeZone = model.TimeZone,
                Terrain = model.Terrain,
                Weather = model.Weather
            };

            _db.Locations.Add(location);
            return(_db.SaveChanges() == 1);
        }
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new ItemLocation()
            {
                SiteName      = model.SiteName,
                StreetAddress = model.StreetAddress,
                City          = model.City,
                State         = model.State
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.ItemLocations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #21
0
        public ActionResult Create(LocationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new LocationService();

            if (service.CreateLocation(model))
            {
                TempData["SaveResult"] = "Location was created.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Location could not be created.");
            return(View(model));
        }
Пример #22
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                CampusId      = model.CampusId,
                LocationName  = model.LocationName,
                Address       = model.Address,
                LocationNotes = model.LocationNotes
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #23
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity = new Location()
            {
                OwnerId      = _userId,
                LocationName = model.LocationName,
                City         = model.City,
                State        = model.State,
                Longitude    = model.Longitude,
                Latitude     = model.Latitude
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #24
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity = new Location
            {
                CreatorId        = _creatorId,
                LocationName     = model.LocationName,
                LocationAddress  = model.LocationAddress,
                IsFamilyFriendly = model.IsFamilyFriendly,
                IsTwentyFourHour = model.IsTwentyFourHour,
                CreatedUtc       = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() > 0);
            }
        }
Пример #25
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                CreatorId = _userId,
                Name      = model.Name,
                Country   = model.Country,
                State     = model.State,
                City      = model.City,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #26
0
        public async Task <IActionResult> Create(LocationCreate viewModel)
        {
            var client = _httpClientFactory.CreateClient("api");

            var content = new StringContent(JsonConvert.SerializeObject(viewModel), System.Text.Encoding.UTF8, "application/json");
            //client.DefaultRequestHeaders
            //      .Accept
            //      .Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(""))

            var result = await client.PostAsync("location", content);

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Пример #27
0
        // Create Location
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                OwnerId      = _userId,
                LocationName = model.LocationName,
                Address      = model.Address,
                IsInside     = model.IsInside,
                TravelTime   = model.TravelTime
            };

            using (ApplicationDbContext ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #28
0
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                Country   = model.Country,
                MetroArea = model.MetroArea,
                Name      = model.Name,
                HistoryId = model.HistoryId,
                GameId    = model.GameId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreateLocation(LocationCreate model)
        {
            var entity =
                new Location()
            {
                Name        = model.Name,
                ClosestCity = model.ClosestCity,
                North       = model.North,
                East        = model.East,
                South       = model.South,
                West        = model.West
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Locations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #30
0
        public ActionResult Create(LocationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateLocationService();

            if (service.CreateLocation(model))
            {
                TempData["SaveResult"] = $"{model.LocationState}, {model.LocationCity} Was Added.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", $"{model.LocationState}, {model.LocationCity} coundn't be added.");

            return(View(model));
        }