예제 #1
0
        public IActionResult EditBurial(Burial b, int SouthToHead, int SouthToFeet, int WestToHead, int WestToFeet, int Length, int Depth, string HairColor)
        {
            var burialEdit       = _context.Burial.Where(x => x.BurialId == b.BurialId).FirstOrDefault();
            var advancedBurial   = _context.BurialAdvanced.Where(y => y.BurialId == b.BurialId).FirstOrDefault();
            int advancedBurialId = advancedBurial.AdvancedId;

            _context.Remove(burialEdit);
            _context.Remove(advancedBurial);
            _context.Burial.Add(b);
            _context.BurialAdvanced.Add(new BurialAdvanced
            {
                AdvancedId      = advancedBurialId,
                BurialId        = b.BurialId,
                SouthToHead     = SouthToHead,
                SouthToFeet     = SouthToFeet,
                EastToHead      = WestToHead,
                EastToFeet      = WestToFeet,
                LengthOfRemains = Length,
                BurialDepth     = Depth,
                HairColor       = HairColor
            });
            _context.SaveChanges();

            return(RedirectToAction("BurialList"));
        }
예제 #2
0
 public async Task <IActionResult> Edit([Bind("BurialId,BurialId2018,YearOnSkull,MonthOnSkull,DateOnSkull,InitialsOfDataEntryExpert,InitialsOfDataEntryChecker,ByuSample,BodyAnalysis,SkullAtMagazine,PostcraniaAtMagazine,AgeSkull2018,RackAndShelf,ToBeConfirmed,SkullTrauma,PostcraniaTrauma,CribraOrbitala,PoroticHyperostosis,PoroticHyperostosisLocations,MetopicSuture,ButtonOsteoma,PostcraniaTrauma1,OsteologyUnknownComment,TemporalMandibularJointOsteoarthritisTmjOa,LinearHypoplasiaEnamel,AreaHillBurials,Tomb,NsLowPosition,NsHighPosition,NorthOrSouth,EwLowPosition,EwHighPosition,EastOrWest,Square,BurialNumber,BurialWestToHead,BurialWestToFeet,BurialSouthToHead,BurialSouthToFeet,BurialDepth,YearExcav,MonthExcavated,DateExcavated,BurialDirection,BurialPreservation,BurialWrapping,BurialAdultChild,Sex,GenderCode,BurialGenderMethod,AgeCodeSingle,BurialDirection1,NumericMinAge,NumericMaxAge,BurialAgeMethod,HairColorCode,BurialSampleTaken,LengthM,LengthCm,Goods,Cluster,FaceBundle,OsteologyNotes,OtherNotes,SampleNumber,GenderGe,GeFunctionTotal,GenderBodyCol,BasilarSuture,VentralArc,SubpubicAngle,SciaticNotch,PubicBone,PreaurSulcus,MedialIpRamus,DorsalPitting,ForemanMagnum,FemurHead,HumerusHead,Osteophytosis,PubicSymphysis,BoneLength,MedialClavicle,IliacCrest,FemurDiameter,Humerus,FemurLength,HumerusLength,TibiaLength,Robust,SupraorbitalRidges,OrbitEdge,ParietalBossing,Gonian,NuchalCrest,ZygomaticCrest,CranialSuture,MaximumCranialLength,MaximumCranialBreadth,BasionBregmaHeight,BasionNasion,BasionProsthionLength,BizygomaticDiameter,NasionProsthion,MaximumNasalBreadth,InterorbitalBreadth,ArtifactsDescription,PreservationIndex,HairTaken,SoftTissueTaken,BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimateLivingStature,ToothAttrition,ToothEruption,PathologyAnomalies,EpiphysealUnion,SsmaTimeStamp,PhotoTaken")] Burial burials)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(burials);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!BurialsExists(burials.BurialId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["AgeCodeSingle"]    = new SelectList(_context.AgeCodes, "AgeCode1", "AgeCode1", burials.AgeCodeSingle);
     ViewData["BurialAdultChild"] = new SelectList(_context.BurialAdultChildren, "BurialAdultChild1", "BurialAdultChild1", burials.BurialAdultChild);
     ViewData["BurialWrapping"]   = new SelectList(_context.BurialWrappings, "BurialWrapping1", "BurialWrapping1", burials.BurialWrapping);
     return(View(burials));
 }
예제 #3
0
        public async Task <ValidationModel <Burial> > InsertAsync(Burial newEntity, CancellationToken cancellationToken = default)
        {
            var validation = await burilValidation.InsertValidationAsync(newEntity, cancellationToken);

            if (!validation.IsValid)
            {
                return(validation);
            }

            newEntity.CreatedAt = DateTime.Now;
            newEntity.UpdatedAt = DateTime.Now;

            validation.Result = await dataBurial.InsertAsync(newEntity, cancellationToken);

            if (newEntity.Files is not null && !newEntity.Files.Count().Equals(0))
            {
                var fileDatas = await fileHelper.SaveFileRange(newEntity.Files);

                foreach (var file in fileDatas)
                {
                    var attachmentForm = new AttachmentBurial()
                    {
                        FilePath = file.FilePath,
                        FileName = file.FileName,
                        FileType = file.FileType,
                        BurialId = validation.Result.Id
                    };

                    await dataAttachmentBurial.InsertAsync(attachmentForm, cancellationToken);
                }
            }

            return(validation);
        }
예제 #4
0
        public IActionResult EditBurialLocation(int burialid)
        {
            Burial      burial      = burialContext.Burial.Where(b => b.BurialId == burialid).FirstOrDefault();
            BasicBurial basicBurial = new BasicBurial
            {
                SingleBurial      = burial,
                SingleLocation    = burialContext.Location.Where(b => b.LocationId == burial.LocationId).FirstOrDefault(),
                SingleSublocation = burialContext.SubLocation.Where(b => b.SublocationId == burial.SublocationId).FirstOrDefault(),
                SingleImage       = burialContext.Image.Where(b => b.BurialId == burial.BurialId).FirstOrDefault()
            };

            //Use Viewbag to store the basic burial information for burial to edit
            ViewBag.BB = basicBurial;

            //Avoid null errors - can't autofill subplot options if subplot is null in form
            if (basicBurial.SingleSublocation.Subplot == null)
            {
                ViewBag.SubplotNull = "true";
            }
            else
            {
                ViewBag.SubplotNull = basicBurial.SingleSublocation.Subplot;
            }

            return(View());
        }
예제 #5
0
        public Burial GetRecord(Guid burialID)
        {
            Burial burial = _context.Burial.Where(b => b.BurialId == burialID).FirstOrDefault();

            burial.Location = _context.Location.Where(x => x.LocationId == burial.LocationId).FirstOrDefault();
            return(burial);
        }
예제 #6
0
        public IActionResult EditFieldNotesBurial2(Burial bu, int BurialID)
        {
            if (ModelState.IsValid)
            {
                var bur = context.Burial.SingleOrDefault(x => x.BurialId == bu.BurialId);

                context.Entry(bur).Property(x => x.BurialNum).CurrentValue            = bu.BurialNum;
                context.Entry(bur).Property(x => x.ArtifactFound).CurrentValue        = bu.ArtifactFound;
                context.Entry(bur).Property(x => x.ArtifactsDescription).CurrentValue = bu.ArtifactsDescription;
                context.Entry(bur).Property(x => x.Cluster).CurrentValue              = bu.Cluster;
                context.Entry(bur).Property(x => x.Goods).CurrentValue                = bu.Goods;
                context.Entry(bur).Property(x => x.BiologicalInitials).CurrentValue   = bu.BiologicalInitials;
                context.Entry(bur).Property(x => x.BiologicalClusterNum).CurrentValue = bu.BiologicalClusterNum;
                context.Entry(bur).Property(x => x.PreviouslySampled).CurrentValue    = bu.PreviouslySampled;
                context.Entry(bur).Property(x => x.BiologicalNotes).CurrentValue      = bu.BiologicalNotes;
                context.Entry(bur).Property(x => x.ToBeConfirmed).CurrentValue        = bu.ToBeConfirmed;
                context.Entry(bur).Property(x => x.BurialSituation).CurrentValue      = bu.BurialSituation;


                context.SaveChanges();

                return(RedirectToAction("BurialList"));
            }
            else
            {
                return(View());
            }
        }
        public async Task InsertValidationAsync_Null_UnSucces()
        {
            // Arrange
            MockData(
                isExistBurial: false,
                isExistBurialById: true,
                isExistTypeBurialById: true
                );
            Burial entity    = null;
            var    listError = new Dictionary <string, string>()
            {
                { nameof(Burial), string.Format(BaseValidation.ObjectNotCanBeNull, nameof(Burial)) }
            };

            // Act
            var result = await _validation.InsertValidationAsync(entity);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.NotNull(result.Errors);
                Assert.IsNotEmpty(result.Errors);
                Assert.IsFalse(result.IsValid);
                foreach (var error in result.Errors)
                {
                    Assert.IsTrue(listError.ContainsKey(error.Key));
                    Assert.AreEqual(listError[error.Key], error.Value);
                }
            });
        }
예제 #8
0
        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"));
            }
        }
예제 #9
0
        private void MockData(
            Burial burial = default,
            AttachmentBurial attachmentBurial = default,
            IEnumerable <Burial> burialList   = default,
            IEnumerable <AttachmentBurial> attachmentBurialList = default,
            ValidationModel <Burial> validationBurial           = default
            )
        {
            _dataBurial.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(burial);
            _dataBurial.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(burialList);
            _dataBurial.Setup(x => x.InsertAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(burial);
            _dataBurial.Setup(x => x.UpdateAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(burial);
            _dataBurial.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _dataAttachmentBurial.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurialList);
            _dataAttachmentBurial.Setup(x => x.InsertAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.UpdateAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _burialValidation.Setup(x => x.GetValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);
            _burialValidation.Setup(x => x.InsertValidationAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);
            _burialValidation.Setup(x => x.UpdateValidationAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);
            _burialValidation.Setup(x => x.DeleteValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);

            _service = new BurialService(_fileHelper.Object, _dataBurial.Object, _dataAttachmentBurial.Object, _burialValidation.Object);
        }
예제 #10
0
        public async Task <Burial> UpdateAsync(Burial entity, CancellationToken cancellationToken)
        {
            db.Burials.Update(entity);
            await db.SaveChangesAsync(cancellationToken);

            return(entity);
        }
예제 #11
0
        //POST: Burials/Create
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see http://go.microsoft.com/fwlink/?LinkId=317598.


        public async Task <IActionResult> Create([Bind("BurialId,BurialNumber,BurialSubplot,BurialSquareId,BurialDepth," +
                                                       "SouthToHead,SouthToFeet,WestToHead,WestToFeet,BurialSituation,BurialWrapping,BurialWrappingMaterial," +
                                                       "BurialAdult,LengthOfRemains,SampleNumber,GenderGe,SexMethodSkull,GeFunctionTotal,GenderBodyCol,HeadDirection," +
                                                       "BasilarSuture,VentralArc,SubpubicAngle,SciaticNotch,PubicBone,PreaurSulcus,MedialIpRamus,DorsalPitting," +
                                                       "ForemanMagnum,FemurHead,HumerusHead,Osteophytosis,PubicSymphysis,FemurLength,HumerusLength,TibiaLength,Robust," +
                                                       "SupraorbitalRidges,OrbitEdge,ParietalBossing,Gonian,NuchalCrest,ZygomaticCrest,CranialSuture,MaximumCranialLength," +
                                                       "MaximumCranialBreadth,BasionBregmaHeight,BasionNasion,BasionProsthionLength,BizygomaticDiameter,NasionProsthion," +
                                                       "MaximumNasalBreadth,InterorbitalBreadth,ArtifactsDescription,HairColor,PreservationIndex,HairTaken,SoftTissueTaken," +
                                                       "BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimateAge,EstimateLivingStature,ToothAttrition," +
                                                       "ToothEruption,PathologyAnomalies,EpiphysealUnion,DateFound,AgeAtDeath,AgeMethodSkull")] Burial burial)
        {
            var role = (wantContext.UserRoles
                        .Where(r => r.UserId == userManager.GetUserId(User))
                        .FirstOrDefault());

            if (!(role is null))
            {
                ViewBag.Role = Int32.Parse(role.RoleId);
            }


            if (ModelState.IsValid)
            {
                _context.Add(burial);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction("Create1", burial));
        }
예제 #12
0
        public async Task <IActionResult> Edit(int id, [Bind("BurialId,BurialLocation,BurialLocationNs,BurialLocationEw,LowPairNs,HighPairNs,LowPairEw,HighPairEw,BurialSubplot,BurialDepth,SouthToHead,SouthToFeet,WestToHead,WestToFeet,BurialSituation,LengthOfRemains,BurialNumber,SampleNumber,GenderGe,GeFunctionTotal,GenderBodyCol,BurialGenderMethod,BasilarSuture,VentralArc,SubpubicAngle,SciaticNotch,PubicBone,PreaurSulcus,MedialIpRamus,DorsalPitting,ForemanMagnum,FemurHead,HumerusHead,Osteophytosis,PubicSymphysis,FemurLength,HumerusLength,TibiaLength,Robust,SupraorbitalRidges,OrbitEdge,ParietalBossing,Gonian,NuchalCrest,ZygomaticCrest,CranialSuture,MaximumCranialLength,MaximumCranialBreadth,BasionBregmaHeight,BasionNasion,BasionProsthionLength,BizygomaticDiameter,NasionProsthion,MaximumNasalBreadth,InterorbitalBreadth,ArtifactsDescription,HairColorCode,HairColorDescription,PreservationIndex,HairTaken,SoftTissueTaken,BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimateAge,AgeCode,EstimateLivingStature,ToothAttrition,ToothEruption,PathologyAnomalies,EpiphysealUnion,YearFound,MonthFound,DayFound,HeadDirection,YearOnSkull,MonthOnSkull,DateOnSkull,FieldBook,FieldBookPageNumber,InitialsOfDataEntryExpert,InitialsOfDataEntryCheker,ByuSample,BodyAnalysis,SkullAtMagazine,PostcraniaAtMagazine,RackAndShelf,ToBeConfirmed,SkullTrama,CribraOrbitala,PoroticHyperostosis,PoroticHyperostosisLocation,MetopicStructure,ButtonOsteoma,PostcraniaTrauma,OsteologyUnknownComment,TemporalMandibularJoinOsteoarthritis,LinearHypoplasiaEnamel,Tomb,AreaHillBurials,BurialPreservation,BurialWrapingCode,BurialAdultChild,Burialagemethod,BurialSampleTaken,Goods,Cluster,FaceBundle,OsteologyNotes")] Burial burial)
        {
            if (id != burial.BurialId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(burial);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BurialExists(burial.BurialId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(burial));
        }
예제 #13
0
        public async Task <IActionResult> Edit(decimal id, [Bind("BurialId,SquareId,AreaId,BurialNumber,SouthToHead,SouthToFeet,WestToHead,WestToFeet,Length,Depth,PhotoTaken,BurialGoods,DateFound,ClusterNumber,SampleNumber,Rack,Shelf,Bag,PreviouslySampled,SexBody,SexGiles,GeFunctionTotal,Description,BasilarSuture,VentralArc,SubPubicAngle,SciaticNotch,PubicBone,PreaurSulcus,MedialIpramus,DorsalPitting,ForemanMagnum,FemurHead,HumerusHead,Osteophytosis,PubicSymphysis,BoneLength,MedialClavicle,IliacCrest,FemurDiameter,Humerus,FemurLength,HumerusLength,TibiaLength,Robust,SupraorbitalRidges,OrbitEdge,ParietalBossing,Gonian,NuchalCrest,ZygomaticCrest,CranialSuture,MaximumCranialLength,MaximumCranialBreadth,BasionBregmaHeight,BasionNasion,BasionProsthionLength,BizygomaticDiameter,NasionProsthion,MaximumNasalBreadth,DecimalerorbitalBreadth,HairColor,PreservationIndex,HairTaken,SoftTissueTaken,BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimatedAge,AgeMethod,EstimateLivingStature,ToothAttrition,ToothEruption,PathologyAnomalies,EpiphysealUnion,HeadDirection,Byusample,BodyAnalysisYear,SkullAtMagazine,PostcraniaAtMagazine,ToBeConfirmed,SkullTrauma,PostcraniaTrauma,CribiaOrbitala,PoroticHyperotosis,PoroticHyperotosisLocations,MetopicSuture,ButtonOsteoma,OsteologyUnknownComment,TmjOa,LinearHypoplasiaEnamel,AreaHillBurials,Tomb,BurialPreservation,BurialWrapping,BurialAdultChild,GenderCode,BurialGenderMethod,AgeCodeSingle,FaceBundle,DateOnSkull")] Burial burial)
        {
            if (id != burial.BurialId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(burial);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BurialExists(burial.BurialId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AreaId"]   = new SelectList(_context.Areas, "AreaId", "Area1", burial.AreaId);
            ViewData["SquareId"] = new SelectList(_context.Squares, "SquareId", "SquareId", burial.SquareId);
            return(View(burial));
        }
예제 #14
0
        public async Task <IActionResult> Edit(int id, [Bind("BurialIdInt,BurialId,BurialLocationNs,BurialLocationEw,LowPairNs,HighPairNs,LowPairEw,HighPairEw,BurialSubplot,BurialDepth,SouthToHead,SouthToFeet,WestToHead,WestToFeet,BurialSituation,LengthOfRemainsMeters,LengthOfRemainsCentimeters,BurialNumber,SampleNumber,GenderGe,GeFunctionTotal,GenderBodyCol,SexMethod,BasilarSuture,VentralArc,SubpubicAngle,SciaticNotch,PubicBone,PreaurSulcus,MedialIpRamus,DorsalPitting,ForamanMagnum,FemurHead,HumerusHead,Osteophytosis,PubicSymphysis,FemurLength,HumerusLength,TibiaLength,Robust,SupraorbitalRidges,OrbitEdge,ParietalBossing,Gonian,NuchalCrest,ZygomaticCrest,CranialSuture,MaximumCranialLength,MaximumCranialBreadth,BasionBregmaHeight,BasionNasion,BasionProsthionLength,BizygomaticDiameter,NasionProsthion,MaximumNasalBreadth,InterorbitalBreadth,ArtifactsDescription,HairColor,PreservationIndex,SampleTaken,HairTaken,SoftTissueTaken,BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimateAge,AgeMethod,AgeCode,EstimateLivingStature,ToothAttrition,ToothEruption,PathologyAnomalies,EpiphysealUnion,YearFound,MonthFound,DayFound,HeadDirection,Gamous,BurialIcon,BurialIcon2,BurialPreservation")] Burial burial)
        {
            ViewBag.NavBar = "Browse";
            if (id != burial.BurialIdInt)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(burial);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BurialExists(burial.BurialIdInt))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(burial));
        }
예제 #15
0
 public IActionResult EditBurialPostBurial(Burial burial)
 {
     context.Burial.Update(burial);
     context.SaveChanges();
     ViewBag.SelectedID = burial.OurId;
     return(View("ViewDetails", burial));
 }
예제 #16
0
        public IActionResult EditBurial(Burial burial)
        {
            IEnumerable <Burial> burials = context.Burial
                                           .Where(b => b.OurId == burial.OurId);

            return(View("EditBurial", burials));
        }
예제 #17
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"));
            }
        }
예제 #18
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"));
            }
        }
예제 #19
0
        public IActionResult EditBurial(BurialViewModel b, int LocationId, DateTime date, int BurialId)
        {
            Burial newB = context.Burial.Single(bur => bur.BurialId == BurialId);

            newB.LocationId                = LocationId;
            newB.BurialNumber              = b.Burial.BurialNumber;
            newB.SouthToHead               = b.Burial.SouthToHead;
            newB.SouthToFeet               = b.Burial.SouthToFeet;
            newB.WestToHead                = b.Burial.WestToHead;
            newB.WestToFeet                = b.Burial.WestToFeet;
            newB.LengthOfRemains           = b.Burial.LengthOfRemains;
            newB.BurialDepth               = b.Burial.BurialDepth;
            newB.ArtifactFound             = b.Burial.ArtifactFound;
            newB.TextileTaken              = b.Burial.TextileTaken;
            newB.HairColor                 = b.Burial.HairColor;
            newB.AgeCodeSingle             = b.Burial.AgeCodeSingle;
            newB.HeadDirection             = b.Burial.HeadDirection;
            newB.InitialsOfDataEntryExpert = b.Burial.InitialsOfDataEntryExpert;
            if (date.ToString("yyyy") != "0001")
            {
                newB.DayFound   = date.ToString("dd");
                newB.MonthFound = date.ToString("MM");
                newB.YearFound  = date.ToString("yyyy");
            }
            context.SaveChanges();
            //Might be good to do a changes made success page.
            return(RedirectToAction("SingleBurial", new { BurialId = BurialId }));
        }
예제 #20
0
        public IActionResult AddBurialSimple(Burial b, int PlotInfo, int month, int day, int year, int SublocationInfo, int SouthToHead, int SouthToFeet, int WestToHead, int WestToFeet, int Length, int Depth)
        {
            //This will grab the largest date id and increment it one to make sure that it is unique
            int dateid = _context.Date.Select(x => x.DateId).Max();

            dateid = dateid + 1;

            //This will add in the date into the date database
            _context.Date.Add(new Date
            {
                DateId = dateid,
                Month  = month,
                Day    = day,
                Year   = year
            });;
            _context.SaveChanges();

            //This will grab the largest burial id
            int burialid = _context.Burial.Select(x => x.BurialId).Max();

            burialid = burialid + 1;
            _context.Burial.Add(new Burial
            {
                BurialId          = burialid,
                RackNum           = b.RackNum,
                BagNum            = b.BagNum,
                BurialNum         = b.BurialNum,
                BurialSubnum      = b.BurialSubnum,
                PreviouslySampled = b.PreviouslySampled,
                Notes             = b.Notes,
                //make this so that the plot info is passed in based on if a new one is created or not
                PlotId = PlotInfo,
                //add in sublocation id here
                SublocationId = SublocationInfo,
                DateId        = dateid
            });
            _context.SaveChanges();
            //add the data to burial advanced
            int advancedid = _context.BurialAdvanced.Select(x => x.AdvancedId).Max();

            advancedid = advancedid + 1;
            _context.BurialAdvanced.Add(new BurialAdvanced
            {
                AdvancedId      = advancedid,
                BurialId        = burialid,
                SouthToFeet     = SouthToFeet,
                SouthToHead     = SouthToFeet,
                EastToFeet      = WestToFeet,
                EastToHead      = WestToHead,
                BurialDepth     = Depth,
                LengthOfRemains = Length
            });



            _context.SaveChanges();
            //int highpairew = (int)p.HighPairEw;
            return(RedirectToAction("BurialList"));
        }
예제 #21
0
        //Deleting a burial record
        public IActionResult DeleteBurial(int burialid)
        {
            Burial burialToDelete = burialContext.Burial.Where(b => b.BurialId == burialid).FirstOrDefault();

            burialContext.Remove(burialToDelete);
            burialContext.SaveChanges();
            return(RedirectToAction("BurialSummaryList"));
        }
예제 #22
0
        public IActionResult DeleteBurialSite(int BurialId)
        {
            Burial burial = _context.Burials.Where(b => b.BurialID == BurialId).FirstOrDefault();

            _context.Remove(burial);
            _context.SaveChanges();
            return(View());
        }
예제 #23
0
        public async Task <Burial> InsertAsync(Burial entity, CancellationToken cancellationToken)
        {
            await db.Burials.AddAsync(entity, cancellationToken);

            await db.SaveChangesAsync(cancellationToken);

            return(entity);
        }
        public IActionResult Delete(int bid)
        {
            Burial burial = _BurialContext.Burials.Find(bid);

            _BurialContext.Remove(burial);
            _BurialContext.SaveChanges();
            return(RedirectToAction("BurialList"));
        }
예제 #25
0
        public IActionResult UploadPhotos(int BurialId)
        {
            Burial burial = _context.Burials.Where(b => b.BurialID == BurialId).FirstOrDefault();

            return(View(new SavePhotoViewModel {
                Burial = burial
            }));
        }
예제 #26
0
        public IActionResult UploadPhotos(int burialId)
        {
            Burial burial = context.Burial.Find(burialId);

            return(View(new SavePhotoViewModel
            {
                Burial = burial
            }));
        }
예제 #27
0
        public IActionResult SingleBurial(int BurialId)
        {
            Burial b = context.Burial.Include(b => b.Location).Single(b => b.BurialId == BurialId);

            return(View(new SavePhotoViewModel
            {
                Burial = b,
                Files = context.Files.Where(f => f.BurialId == BurialId)
            }));
        }
예제 #28
0
        public IActionResult EditBurial(int BurialId)
        {
            Burial burial = _context.Burials.Where(b => b.BurialID == BurialId).FirstOrDefault();
            EditBurialViewModel BurialEdit = new EditBurialViewModel(_context)
            {
                Burial = burial
            };

            return(View(BurialEdit));
        }
예제 #29
0
        public async Task TestUpdateAsync()
        {
            // Arrange
            var random = new Random(0);
            var number = random.Next(5);
            var entity = GetList()[number];
            await _service.InsertAsync(entity);

            _dbContext.Entry(entity).State            = EntityState.Detached;
            _dbContext.Entry(entity.TypeBurial).State = EntityState.Detached;

            entity = new Burial()
            {
                Id            = entity.Id,
                NumberBurial  = 10,
                Location      = "ул. Ленина 42, Глубокое",
                KnownNumber   = 1,
                UnknownNumber = 1,
                Year          = 2000,
                Latitude      = 28.01228,
                Longitude     = 32.01228,
                Description   = "Описание 221",
                TypeBurialId  = Guid.NewGuid(),
                TypeBurial    = GetTypeBurial(),
                CreatedAt     = DateTime.Now.AddMinutes(60),
                UpdatedAt     = DateTime.Now.AddMinutes(60)
            };
            await _service.UpdateAsync(entity);

            _dbContext.Entry(entity).State            = EntityState.Detached;
            _dbContext.Entry(entity.TypeBurial).State = EntityState.Detached;

            // Act
            var result = await _service.GetAsync(entity.Id);

            _dbContext.Entry(result).State            = EntityState.Detached;
            _dbContext.Entry(result.TypeBurial).State = EntityState.Detached;

            // Assert
            Assert.Multiple(() =>
            {
                Assert.IsTrue(entity.NumberBurial == result.NumberBurial);
                Assert.IsTrue(entity.Location == result.Location);
                Assert.IsTrue(entity.KnownNumber == result.KnownNumber);
                Assert.IsTrue(entity.UnknownNumber == result.UnknownNumber);
                Assert.IsTrue(entity.Year == result.Year);
                Assert.IsTrue(entity.Latitude == result.Latitude);
                Assert.IsTrue(entity.Longitude == result.Longitude);
                Assert.IsTrue(entity.Description == result.Description);
                Assert.IsTrue(entity.TypeBurialId == result.TypeBurialId);
                Assert.IsTrue(entity.CreatedAt == result.CreatedAt);
                Assert.IsTrue(entity.UpdatedAt == result.UpdatedAt);
            });
        }
예제 #30
0
        public IActionResult Artifact(int BurialId)
        {
            TempData["BurialId"] = BurialId;
            Burial burial = context.Burial.Single(b => b.BurialId == BurialId);

            return(View(new ArtifactViewModel {
                Artifacts = context.Artifacts.Where(a => a.BurialId == BurialId),
                Burial = burial,
                Location = context.Location.Single(l => l.LocationId == burial.LocationId)
            }));
        }