public static string InsertCoordinates(ForestCoordinate forestCoordinates) { using (var db = new DefaultCS()) { db.ForestCoordinates.AddObject(forestCoordinates); db.SaveChanges(); } return "true"; }
public Int64? UpdateArea(ForestArea forestArea, ForestCoordinate[] forestCoordinates) { IFormatProvider provider = new System.Globalization.CultureInfo("en-GB", true); using (var db = new DefaultCS()) { try { var fUpdate = db.ForestAreas.Where(i => i.Id == forestArea.Id).First(); foreach (var fcc in forestCoordinates) { var forestC = db.ForestCoordinates.Where(i => i.Id == fcc.Id).First(); forestC.BackBearings = fcc.BackBearings; forestC.BackDistanceInChain = fcc.BackDistanceInChain; forestC.BackDistanceInMeter = fcc.BackDistanceInMeter; forestC.BearingDifference = fcc.BearingDifference; forestC.ForwardBearings = fcc.ForwardBearings; forestC.Latitude = fcc.Latitude; forestC.Longitude = fcc.Longitude; forestC.PillarNo = fcc.PillarNo; forestC.LatitudeField = fcc.LatitudeField; forestC.LongitudeField = fcc.LongitudeField; } fUpdate.AreaInField = forestArea.AreaInField; fUpdate.AreaCalculated = forestArea.AreaCalculated; fUpdate.AreaInGazette = forestArea.AreaInGazette; fUpdate.BlockId = forestArea.BlockId; fUpdate.ForestName = forestArea.ForestName; fUpdate.ForestType = forestArea.ForestType; fUpdate.GazetteNo = forestArea.GazetteNo; fUpdate.isReferencePoint = forestArea.isReferencePoint; fUpdate.NumberOfPillars = forestArea.NumberOfPillars; fUpdate.VillageId = forestArea.VillageId; //fUpdate.GazetteDate = DateTime.Parse(forestArea.GazetteDate.ToString(), provider); fUpdate.GazetteDate = forestArea.GazetteDate; fUpdate.UpdatedDate = DateTime.Now; fUpdate.UpdatedBy = forestArea.UpdatedBy; db.SaveChanges(); return forestArea.Id; } catch (Exception ex) { return null; } } }
public Int64? InsertArea(ForestArea forestArea, ForestCoordinate[] forestCoordinates) { using (var db = new DefaultCS()) { try { EntityCollection<ForestCoordinate> fc = new EntityCollection<ForestCoordinate>(); foreach (var fcc in forestCoordinates) { fc.Add(fcc); } forestArea.ForestCoordinates = fc; forestArea.CreatedDate = DateTime.Now; db.ForestAreas.AddObject(forestArea); db.SaveChanges(); return forestArea.Id; } catch (Exception ex) { return null; } } }
/// <summary> /// Deprecated Method for adding a new object to the ForestCoordinates EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToForestCoordinates(ForestCoordinate forestCoordinate) { base.AddObject("ForestCoordinates", forestCoordinate); }
/// <summary> /// Create a new ForestCoordinate object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="forestAreaId">Initial value of the ForestAreaId property.</param> public static ForestCoordinate CreateForestCoordinate(global::System.Int64 id, global::System.Int64 forestAreaId) { ForestCoordinate forestCoordinate = new ForestCoordinate(); forestCoordinate.Id = id; forestCoordinate.ForestAreaId = forestAreaId; return forestCoordinate; }