public ActionResult SurveyProfileEdit(SurveyProfileEdit data, string prevBtn, string nextBtn) { SurveyWizard obj = GetSurvey(); ViewBag.Village = obj.GeoSurvey.Village; ViewBag.VesPoints = new SelectList(DropVs.VsPoints.ToList(), "Id", "Number"); ViewBag.SurveyTypes = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name"); var geosurvey1 = Database.Session.Load <GeoSurvey>(data.SurveyId); if (nextBtn != null) { if (ModelState.IsValid) { var surveyProfile1 = Database.Session.Load <SurveyProfile>(data.ProfileEditor1.Id); var surveyProfile2 = Database.Session.Load <SurveyProfile>(data.ProfileEditor2.Id); var surveyProfile3 = Database.Session.Load <SurveyProfile>(data.ProfileEditor3.Id); int surveyMethod1 = Convert.ToInt32(data.ProfileEditor1.SurveyMethod); int surveyMethod2 = Convert.ToInt32(data.ProfileEditor2.SurveyMethod); int surveyMethod3 = Convert.ToInt32(data.ProfileEditor3.SurveyMethod); surveyProfile1.VesPoint = Convert.ToInt32(data.ProfileEditor1.VESPoints); surveyProfile1.Northing = data.ProfileEditor1.Northing; surveyProfile1.Easting = data.ProfileEditor1.Easting; surveyProfile1.Elevation = data.ProfileEditor1.Elevation; surveyProfile1.SurveyMethod = SurveyTypeName(surveyMethod1); surveyProfile1.Recommend = data.ProfileEditor1.Recommend; surveyProfile2.VesPoint = Convert.ToInt32(data.ProfileEditor2.VESPoints); surveyProfile2.Northing = data.ProfileEditor2.Northing; surveyProfile2.Easting = data.ProfileEditor2.Easting; surveyProfile2.Elevation = data.ProfileEditor2.Elevation; surveyProfile2.SurveyMethod = SurveyTypeName(surveyMethod2); surveyProfile2.Recommend = data.ProfileEditor2.Recommend; surveyProfile3.VesPoint = Convert.ToInt32(data.ProfileEditor3.VESPoints); surveyProfile3.Northing = data.ProfileEditor3.Northing; surveyProfile3.Easting = data.ProfileEditor3.Easting; surveyProfile3.Elevation = data.ProfileEditor3.Elevation; surveyProfile3.SurveyMethod = SurveyTypeName(surveyMethod3); surveyProfile3.Recommend = data.ProfileEditor3.Recommend; obj.GeoSurvey.SiteRecommendation = data.ProfileEditor1.SiteRecommendation; var client = obj.Client; var geosurvey = obj.GeoSurvey; geosurvey1.Client.Name = client.Name; geosurvey1.Client.Address = client.Address; geosurvey1.Client.Phone = client.Phone; geosurvey1.Client.Email = client.Email; geosurvey1.Client.Region = client.Region; geosurvey1.Region = geosurvey.Region; geosurvey1.District = geosurvey.District; geosurvey1.Village = geosurvey.Village; geosurvey1.SurveyType = geosurvey.SurveyType; geosurvey1.Cost = geosurvey.Cost; geosurvey1.Staff = geosurvey.Staff; geosurvey1.StartDate = geosurvey.StartDate; geosurvey1.EndDate = geosurvey.EndDate; geosurvey1.SiteRecommendation = geosurvey.SiteRecommendation; Database.Session.Update(geosurvey1); Database.Session.Update(surveyProfile1); Database.Session.Update(surveyProfile2); Database.Session.Update(surveyProfile3); ViewBag.ActionMethod = "Edit"; RemoveSurvey(); return(PartialView("Success")); } } return(PartialView()); }
public ActionResult EditSurveyClient(SurveyEdit data, string prevBtn, string nextBtn) { //var geosurvey = Database.Session.Load<GeoSurvey>(Id); //List<SurveyProfile> surveyProfile = new List<SurveyProfile>(); var surveyProfile = Database.Session.Query <SurveyProfile>().Where(x => x.GeoSurvey.Id == data.surveyId).ToList <SurveyProfile>(); ViewBag.SurveyTypes1 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[0].SurveyMethod)); ViewBag.SurveyTypes2 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[1].SurveyMethod)); ViewBag.SurveyTypes3 = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name", SurveyTypeId(surveyProfile[2].SurveyMethod)); var model = new SurveyProfileEdit(); model.SurveyId = data.surveyId; model.ProfileEditor1.Id = surveyProfile[0].Id; model.ProfileEditor1.VESPoints = surveyProfile[0].VesPoint.ToString(); model.ProfileEditor1.Northing = surveyProfile[0].Northing; model.ProfileEditor1.Easting = surveyProfile[0].Easting; model.ProfileEditor1.Elevation = surveyProfile[0].Elevation; //model.profileeditor1.surveymethod = surveyprofile[0].surveymethod; model.ProfileEditor1.Recommend = surveyProfile[0].Recommend; model.ProfileEditor1.SiteRecommendation = data.SiteRecommendation; model.ProfileEditor2.Id = surveyProfile[1].Id; model.ProfileEditor2.VESPoints = surveyProfile[1].VesPoint.ToString(); model.ProfileEditor2.Northing = surveyProfile[1].Northing; model.ProfileEditor2.Easting = surveyProfile[1].Easting; model.ProfileEditor2.Elevation = surveyProfile[1].Elevation; //model.profileeditor1.surveymethod = surveyprofile[0].surveymethod; model.ProfileEditor2.Recommend = surveyProfile[1].Recommend; model.ProfileEditor3.Id = surveyProfile[2].Id; model.ProfileEditor3.VESPoints = surveyProfile[2].VesPoint.ToString(); model.ProfileEditor3.Northing = surveyProfile[2].Northing; model.ProfileEditor3.Easting = surveyProfile[2].Easting; model.ProfileEditor3.Elevation = surveyProfile[2].Elevation; //model.profileeditor1.surveymethod = surveyprofile[0].surveymethod; model.ProfileEditor3.Recommend = surveyProfile[2].Recommend; SurveyWizard obj = GetSurvey(); if (nextBtn != null) { ViewBag.VesPoints = new SelectList(DropVs.VsPoints.ToList(), "Id", "Number"); ViewBag.SurveyTypes = new SelectList(SurveyorDrop.surveyorTypes.ToList(), "Id", "Name"); ViewBag.Village = data.Village; var client = new Client(); var geosurvey = new GeoSurvey(); int regionClientId = Convert.ToInt32(data.Client.Region); int regionGeosurveyId = Convert.ToInt32(data.Region); int geosurveyDistrictId = Convert.ToInt32(data.District); int geosurveyStaffId = Convert.ToInt32(data.SurveyorName); if (geosurveyStaffId == 0) { geosurveyStaffId = 5; } client.Name = data.Client.Name; client.Address = data.Client.Address; client.Region = Regions.Where(x => x.Id == regionClientId).FirstOrDefault <Region>(); client.Phone = data.Client.Phone; client.Email = data.Client.Email; geosurvey.Region = Regions.Where(x => x.Id == regionGeosurveyId).FirstOrDefault <Region>(); geosurvey.District = Districts.Where(x => x.Id == geosurveyDistrictId).FirstOrDefault <District>(); geosurvey.Village = data.Village; geosurvey.SurveyType = data.SurveyorType; geosurvey.Cost = data.Cost; geosurvey.Staff = Staffs.Where(x => x.Id == geosurveyStaffId).FirstOrDefault <Staff>(); geosurvey.StartDate = data.StartDate; geosurvey.EndDate = data.EndDate; obj.Client = client; obj.GeoSurvey = geosurvey; return(PartialView("SurveyProfileEdit", model)); } return(PartialView()); }