public void DeleteAttribute(int loadId, int?resourcePlanId, int?phaseId) { LoadAttribute loadAttribute = this.Context.LoadAttributes.FirstOrDefault(la => la.LoadId == loadId && la.ResourcePlanId == resourcePlanId && la.ProjectPhaseId == phaseId); if (loadAttribute == null) { return; } this.Context.LoadAttributes.DeleteOnSubmit(loadAttribute); this.Context.SubmitChanges(); }
/// <summary> /// Inserts any new LoadAttribute object to Db or updates an existing LoadAttribute object (based on LoadId and ResourcePlanId) /// </summary> /// <param name="LoadAttribute">LoadAttribute object</param> public void SaveLoadAttribute(LoadAttribute loadAttribute) { LoadAttribute currentLoadAttribute = this.Context.LoadAttributes.FirstOrDefault(la => la.LoadId == loadAttribute.LoadId && la.ResourcePlanId == loadAttribute.ResourcePlanId && !la.ProjectPhaseId.HasValue); if (currentLoadAttribute != null) { UpdateLoadAttribute(currentLoadAttribute, loadAttribute); } else { this.Context.LoadAttributes.InsertOnSubmit(loadAttribute); } this.Context.SubmitChanges(); }
/// <summary> /// Inserts any new LoadAttribute object to Db or updates an existing LoadAttribute object (based on LoadId and ResourcePlanId) /// </summary> /// <param name="LoadAttribute">LoadAttribute object</param> public void Save(LoadAttribute la) { LoadAttribute currentLa = this.Context.LoadAttributes.FirstOrDefault(lat => lat.LoadId == la.Id && lat.ResourcePlanId == la.ResourcePlanId && (!lat.ProjectPhaseId.HasValue || lat.ProjectPhaseId == la.ProjectPhaseId)); if (currentLa != null) { UpdateLoadAttribute(currentLa, la); } else { this.Context.LoadAttributes.InsertOnSubmit(la); } this.Context.SubmitChanges(); }
/// <summary> /// Inserts any new LoadAttribute object to Db or updates an existing LoadAttribute object (based on LoadId, ResourcePlanId & ProjectPhaseId) /// </summary> /// <param name="LoadAttribute">LoadAttribute object</param> public bool SaveLoadAttributeAgainstPhase(LoadAttribute loadAttribute) { bool isNewToPhase = false; LoadAttribute currentLoadAttribute = this.Context.LoadAttributes.FirstOrDefault(la => la.LoadId == loadAttribute.LoadId && la.ResourcePlanId == loadAttribute.ResourcePlanId && la.ProjectPhaseId == loadAttribute.ProjectPhaseId); if (currentLoadAttribute != null) { UpdateLoadAttribute(currentLoadAttribute, loadAttribute); } else { this.Context.LoadAttributes.InsertOnSubmit(loadAttribute); isNewToPhase = true; } this.Context.SubmitChanges(); return(isNewToPhase); }
private void UpdateLoadAttribute(LoadAttribute currentLoadAttribute, LoadAttribute newLoadAttribute) { currentLoadAttribute.UserUpdatedId = newLoadAttribute.UserCreatedId; currentLoadAttribute.DateUpdated = newLoadAttribute.DateCreated; currentLoadAttribute.DateEffective = newLoadAttribute.DateEffective; currentLoadAttribute.DateEnd = newLoadAttribute.DateEnd; currentLoadAttribute.DateReplaced = newLoadAttribute.DateReplaced; currentLoadAttribute.InServiceEndDate = newLoadAttribute.InServiceEndDate; currentLoadAttribute.InServiceStartDate = newLoadAttribute.InServiceStartDate; currentLoadAttribute.LoadGrossSummerMin = newLoadAttribute.LoadGrossSummerMin; currentLoadAttribute.LoadGrossSummerPeak = newLoadAttribute.LoadGrossSummerPeak; currentLoadAttribute.LoadGrossWinterMin = newLoadAttribute.LoadGrossWinterMin; currentLoadAttribute.LoadGrossWinterPeak = newLoadAttribute.LoadGrossWinterPeak; currentLoadAttribute.LoadMw = newLoadAttribute.LoadMw; currentLoadAttribute.PowerFactor = newLoadAttribute.PowerFactor; currentLoadAttribute.Probability = newLoadAttribute.Probability; currentLoadAttribute.ESALoadDemand = newLoadAttribute.ESALoadDemand; currentLoadAttribute.LoadGbl = newLoadAttribute.LoadGbl; newLoadAttribute.Id = currentLoadAttribute.Id; }
/// <summary> /// Inserts any new LoadAttribute object to Db or updates an existing LoadAttribute object (based on LoadId, ResourcePlanId & ProjectPhaseId) /// Updates input reference param currentGeneratorAttribute with pre update state. currentLoadAttribute remains null when the object is new /// </summary> /// <param name="LoadAttribute">LoadAttribute object</param> public bool SaveLoadAttributeAgainstPhase(LoadAttribute newLoadAttribute, ref LoadAttribute currentLoadAttribute) { bool isNewToPhase = false; LoadAttribute exisitingLoadAttribute = this.Context.LoadAttributes.FirstOrDefault(la => la.LoadId == newLoadAttribute.LoadId && la.ResourcePlanId == newLoadAttribute.ResourcePlanId && la.ProjectPhaseId == newLoadAttribute.ProjectPhaseId); if (exisitingLoadAttribute != null) { currentLoadAttribute = exisitingLoadAttribute.Clone(); UpdateLoadAttribute(exisitingLoadAttribute, newLoadAttribute); } else { this.Context.LoadAttributes.InsertOnSubmit(newLoadAttribute); isNewToPhase = true; } this.Context.SubmitChanges(); return(isNewToPhase); }
public LoadAttribute Clone() { LoadAttribute clone = new LoadAttribute(); clone.LoadId = this.LoadId; clone.ResourcePlanId = this.ResourcePlanId; clone.ProjectPhaseId = this.ProjectPhaseId; clone.DateEffective = this.DateEffective; clone.DateEnd = this.DateEnd; clone.DateReplaced = this.DateReplaced; clone.InServiceEndDate = this.InServiceEndDate; clone.InServiceStartDate = this.InServiceStartDate; clone.LoadGrossSummerMin = this.LoadGrossSummerMin; clone.LoadGrossSummerPeak = this.LoadGrossSummerPeak; clone.LoadGrossWinterMin = this.LoadGrossWinterMin; clone.LoadGrossWinterPeak = this.LoadGrossWinterPeak; clone.LoadMw = this.LoadMw; clone.PowerFactor = this.PowerFactor; clone.Probability = this.Probability; clone.ESALoadDemand = this.ESALoadDemand; clone.LoadGbl = this.LoadGbl; return(clone); }