public void DonorRegister(Donors donor) { context.Donors.Add(donor); context.SaveChanges(); Console.WriteLine("Register successful! Redirecting..."); DonorLogin(donor.Email, donor.Password); }
public void ChangeDonorStatus(Donors donor) { var updatedDonor = context.Donors.First(d => d.DonorId == donor.DonorId); updatedDonor.Status = "Available"; context.SaveChanges(); }
/// <summary>Registers the donor.</summary> /// <param name="donor">The donor.</param> /// <returns> /// <c>true</c> if register successful, <c>false</c> otherwise.</returns> public bool DonorRegister(Donor donor) { if (!EmailAlreadyExists(donor.Email, true)) { context.Donors.Add(donor); context.SaveChanges(); return(true); } return(false); }
public ActionResult Create(Donor Donors) { if (ModelState.IsValid) { db.Donors.Add(Donors); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(Donors)); }
/// <summary>Deletes the patient from the database.</summary> /// <param name="patient">The patient.</param> public void DeletePatient(Patient patient) { var patientToDelete = context.Patients.First(p => p.PatientId == patient.PatientId); context.Patients.Remove(patientToDelete); context.SaveChanges(); }
public ActionResult DeleteAssessment(int id) { if (id != 0) { //find the assessment from the dbcontext ModelState.Clear(); BloodDonors.Models.Assessment thisAssessment = db.Assessments.Find(id); if (thisAssessment != null) { //remove subobjects first foreach (BloodDonors.Models.Borehole thisBH in thisAssessment.Boreholes) { db.BHSamples.RemoveRange(db.BHSamples.Where(x => x.BoreholdID == thisBH.BoreholeID)); db.SaveChanges(); } db.Boreholes.RemoveRange(db.Boreholes.Where(x => x.AssessmentID == thisAssessment.AssessmentID)); foreach (BloodDonors.Models.Transect thisT in thisAssessment.Transects) { db.TransectPoints.RemoveRange(db.TransectPoints.Where(x => x.TransectID == thisT.TransectId)); db.SaveChanges(); db.TransectImages.RemoveRange(db.TransectImages.Where(x => x.TransectID == thisT.TransectId)); db.SaveChanges(); } db.Transects.RemoveRange(db.Transects.Where(x => x.AssessmentID == thisAssessment.AssessmentID)); db.Assessments.Remove(thisAssessment); db.Entry(thisAssessment).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(Redirect(Request.UrlReferrer.ToString())); } else { return(View("Index"));; } } return(View("Index"));; }
public ActionResult Open(int id) { string theToken = ""; try { string ClientID = "elBvfMc5CdkWaMJv"; string ClientSecret = "a4b4b1bcbfc544e5934f235093975f10"; AGOL thisAgol = new AGOL(ClientID, ClientSecret); theToken = thisAgol.GetToken(ClientID, ClientSecret); } catch (Exception e) { } ViewBag.EsriToken = theToken; if (id != 0) { //find the assessment from the dbcontext ModelState.Clear(); BloodDonors.Models.Assessment thisAssessment = db.Assessments.Find(id); if (thisAssessment != null) { EvaluateStability(thisAssessment); return(View("Index", thisAssessment)); } else { return(null); } } else { //check if logged in. If not, then force login BloodDonors.Models.Assessment thisAssessment = new BloodDonors.Models.Assessment(); thisAssessment.UserID = new Guid(Membership.GetUser().ProviderUserKey.ToString()); thisAssessment.CreatedDate = DateTime.Now; thisAssessment.LastModifiedDate = DateTime.Now; thisAssessment.AssessmentID = 1; thisAssessment.AssessmentName = "New Assessment"; thisAssessment.StructureType = Models.StructureType.Light; thisAssessment.LightStructureUse = BloodDonors.Models.LightStructureUse.Offices; thisAssessment.HeavyStructureUse = BloodDonors.Models.HeavyStructureUse.Hospital; thisAssessment.LinearStructureUse = BloodDonors.Models.LinearStructureUse.Road; thisAssessment.CurrentStep = "WS0"; thisAssessment.FoundationElevation = BloodDonors.Models.FoundationElevation.Grade; thisAssessment.LifeSafetyRequirement = BloodDonors.Models.LifeSafetyRequirement.Med; thisAssessment.AcceptableFoundationFailureRiskLevel = BloodDonors.Models.AcceptableFoundationFailureRiskLevel.Low; thisAssessment.StructureHeated = BloodDonors.Models.StructureHeated.Heated; thisAssessment.ObservedIceWedges = BloodDonors.Models.ObservedIceWedges.NoIceWedges; thisAssessment.TopographyEstimate = BloodDonors.Models.TopographyEstimate.Moderate; thisAssessment.ThermoKarstPresent = Models.ThermoKarstPresent.NoThermoKarstPresent; thisAssessment.VegetationType = Models.VegetationType.Deciduous; thisAssessment.BlackSprucePresent = BloodDonors.Models.BlackSprucePresent.BlackSpruceNotPresent; thisAssessment.DrunkenForestPresent = BloodDonors.Models.DrunkenForestPresent.DrunkenForestNotPresent; thisAssessment.StreamsPresent = BloodDonors.Models.StreamsPresent.StreamsNotPresent; thisAssessment.MarshesStandingWaterPresent = BloodDonors.Models.MarshesStandingWaterPresent.MarshesStandingWaterPresentNotPresent; thisAssessment.ExistingStructureType = Models.ExistingStructureType.Light; thisAssessment.ExistingStructuresHeated = BloodDonors.Models.ExistingStructuresHeated.ExistingStructuresNotHeated; thisAssessment.ExistingStructuresFoundationCondition = BloodDonors.Models.ExistingStructuresFoundationCondition.Good; thisAssessment.SiteLatitude = 62.0; thisAssessment.SiteLongitude = -100.0; thisAssessment.AssessmentArea = 0.0; thisAssessment.StructureLength = 50.0; thisAssessment.StructureWidth = 50.0; thisAssessment.LifeSpan = 30; thisAssessment.Stories = 1; thisAssessment.MT = 0; thisAssessment.IC = 0; thisAssessment.V = 0; thisAssessment.R = 0; thisAssessment.C = 0; thisAssessment.DDF = 0; thisAssessment.ShapeCoordinates = "0,0"; thisAssessment.Boreholes = new List <Models.Borehole>(); if (ModelState.IsValid) { try { db.Configuration.AutoDetectChangesEnabled = true; db.Assessments.Add(thisAssessment); this.CurrentAssessmentID = thisAssessment.AssessmentID; db.SaveChanges(); this.CurrentAssessmentID = thisAssessment.AssessmentID; // return RedirectToAction("Index"); Console.Write(thisAssessment.AssessmentID); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } return(View("Index", thisAssessment)); } }