Beispiel #1
0
        public string SaveParkImage(IFormFile Image, int ParkId, string Title, string Description)
        {
            if (Image == null)
            {
                return("The file was not found");
            }
            var NewImage = new ParkImage()
            {
                Image       = ImageToByteArray(Image),
                ParkId      = ParkId,
                Title       = Title,
                Description = Description
            };

            _ctx.ParkImages.Add(NewImage);
            _ctx.SaveChanges();
            return("The file was saved");
        }
Beispiel #2
0
        public void Seed()
        {
            _ctx.Database.EnsureCreated();

            if (!_ctx.ParkLists.Any())
            {
                //create park list data
                var filepath = Path.Combine(_hosting.ContentRootPath, "Data/parklistinfo.json");
                var json     = File.ReadAllText(filepath);
                var parklist = JsonConvert.DeserializeObject <IEnumerable <ParkList> >(json);
                _ctx.ParkLists.AddRange(parklist);
                _ctx.SaveChanges();
            }
        }