public Int64? InsertArea1(ForestArea forestArea, CadastralPoint[] cadastralPoints) { using (var db = new DefaultCS()) { try { if (cadastralPoints != null) { EntityCollection<CadastralPoint> cp = new EntityCollection<CadastralPoint>(); foreach (var cpp in cadastralPoints) { cp.Add(cpp); } forestArea.CadastralPoints1 = cp; } 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 CadastralPoints EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCadastralPoints(CadastralPoint cadastralPoint) { base.AddObject("CadastralPoints", cadastralPoint); }
/// <summary> /// Create a new CadastralPoint object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="forestAreaId">Initial value of the ForestAreaId property.</param> public static CadastralPoint CreateCadastralPoint(global::System.Int64 id, global::System.Int64 forestAreaId) { CadastralPoint cadastralPoint = new CadastralPoint(); cadastralPoint.Id = id; cadastralPoint.ForestAreaId = forestAreaId; return cadastralPoint; }
public Int64? UpdateArea1(ForestArea forestArea, CadastralPoint[] cadastralPoints) { 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(); if (cadastralPoints != null) { foreach (var cpp in cadastralPoints) { try { var CC = db.CadastralPoints.Where(i => i.ForestAreaId == fUpdate.Id); foreach (CadastralPoint ccc in CC) { db.CadastralPoints.DeleteObject(ccc); } } catch (Exception) { } cpp.ForestAreaId = fUpdate.Id; db.CadastralPoints.AddObject(cpp); } } fUpdate.AreaInGazette = forestArea.AreaInGazette; fUpdate.BlockId = forestArea.BlockId; fUpdate.ForestName = forestArea.ForestName; fUpdate.ForestType = forestArea.ForestType; fUpdate.GazetteNo = forestArea.GazetteNo; fUpdate.CadastralPoints = forestArea.CadastralPoints; 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; } } }