示例#1
0
        public async Task <IActionResult> SavePhotos(SavePhotoViewModel SavePhoto, int burialId)
        {
            if (ModelState.IsValid)
            {
                string url = await _s3storage.AddItem(SavePhoto.PhotoFile, "test");

                Burial burial_to_add = context.Burial.Find(burialId);

                Files FileRecord = new Files
                {
                    FileUrl  = url,
                    Type     = SavePhoto.Type,
                    Burial   = burial_to_add,
                    BurialId = burial_to_add.BurialId
                };

                context.Add(FileRecord);
                context.SaveChanges();
                return(RedirectToAction("SingleBurial", new { BurialId = burialId }));
            }
            else
            {
                return(View("ErrorBurial"));
            }
        }
        public async Task <IActionResult> SavePhotos(SavePhotoViewModel SavePhoto, int BurialId)
        {
            // save iploaded photo yeet
            if (ModelState.IsValid)
            {
                Burial burial_to_add = _context.Burials.Where(b => b.BurialID == BurialId).FirstOrDefault();
                string url           = await _s3storage.AddItem(SavePhoto.PhotoFile, burial_to_add.DisplayBurialLocation(), SavePhoto.Type);


                FileUrl FileRecord = new FileUrl(_context)
                {
                    Url      = url,
                    Type     = SavePhoto.Type,
                    Burial   = burial_to_add,
                    BurialID = burial_to_add.BurialID
                };


                _context.Add(FileRecord);
                _context.SaveChanges();
                return(Redirect("/Research/AddSite"));
            }
            else
            {
                return(View("UploadPhotos"));
            }
        }
示例#3
0
        public async Task <IActionResult> SavePhotos(SavePhotoViewModel SavePhoto, int id)
        {
            if (ModelState.IsValid)
            {
                string url = await _s3storage.AddItem(SavePhoto.PhotoFile, "testGuy");

                Burial burial_to_add = context.Burial.Where(b => b.OurId == id).FirstOrDefault();

                Pictures FileRecord = new Pictures()
                {
                    PicUrl = url,
                    PicId  = context.Pictures
                             .Select(p => p.PicId)
                             .Last() + 1,
                    OurID = id,
                    Type  = SavePhoto.Type
                };

                context.Pictures.Add(FileRecord);
                context.SaveChanges();
                ViewBag.SelectedID = ViewBag.OurID;
                return(View("ViewDetails", burial_to_add));
            }
            else
            {
                return(View("PhotoUploadForm"));
            }
        }