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")); }
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)); }
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); }
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()); }
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); }
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); } }); }
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")); } }
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); }
public async Task <Burial> UpdateAsync(Burial entity, CancellationToken cancellationToken) { db.Burials.Update(entity); await db.SaveChangesAsync(cancellationToken); return(entity); }
//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)); }
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)); }
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)); }
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)); }
public IActionResult EditBurialPostBurial(Burial burial) { context.Burial.Update(burial); context.SaveChanges(); ViewBag.SelectedID = burial.OurId; return(View("ViewDetails", burial)); }
public IActionResult EditBurial(Burial burial) { IEnumerable <Burial> burials = context.Burial .Where(b => b.OurId == burial.OurId); return(View("EditBurial", burials)); }
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")); } }
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 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 })); }
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")); }
//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")); }
public IActionResult DeleteBurialSite(int BurialId) { Burial burial = _context.Burials.Where(b => b.BurialID == BurialId).FirstOrDefault(); _context.Remove(burial); _context.SaveChanges(); return(View()); }
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")); }
public IActionResult UploadPhotos(int BurialId) { Burial burial = _context.Burials.Where(b => b.BurialID == BurialId).FirstOrDefault(); return(View(new SavePhotoViewModel { Burial = burial })); }
public IActionResult UploadPhotos(int burialId) { Burial burial = context.Burial.Find(burialId); return(View(new SavePhotoViewModel { Burial = burial })); }
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) })); }
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)); }
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); }); }
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) })); }