public static bool HasSameEntity(Service entity) { EntityModelContainer context = entity.Context; if (entity.EntityState == EntityState.Unchanged) return false; if (context.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified | EntityState.Unchanged) .Select(e => e.Entity).OfType<Service>().Any(x => x.Title == entity.Title && (x != entity))) return true; return false; }
public static InsuranceDef[] GetInsuranceDefs(Patient patient, Service service) { EntityModelContainer context = GetContext(); List<InsuranceDef> lstResult = new List<InsuranceDef>(); InsPtn[] patientInsurances = context.InsPtns.Execute(MergeOption.NoTracking) .Where(ip => ip.PatientId == patient.Id).ToArray(); foreach (var patientInsurance in patientInsurances) { lstResult.AddRange ( context.InsuranceDefs.Include("Insurance").Include("Service").Execute(MergeOption.OverwriteChanges) .Where(id => id.InsuranceId==patientInsurance.InsuranceId && id.ServiceId == service.Id && id.Fee>0).ToArray() ); } return lstResult.ToArray(); }
/// <summary> /// Create a new Service object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="price">Initial value of the Price property.</param> public static Service CreateService(global::System.Int32 id, global::System.String title, global::System.Double price) { Service service = new Service(); service.Id = id; service.Title = title; service.Price = price; return service; }
public static bool Validate(Service entity) { if (entity.Title == null || entity.Title.Trim().Length == 0) { Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.ServiceTitleNull); return false; } if (entity.Price == null) { Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.ServicePriceNull); return false; } if (entity.ServiceCategoryRelations.Count == 0) { Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.ServiceCategoriesNull); return false; } return true; }
/// <summary> /// Deprecated Method for adding a new object to the Services EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToServices(Service service) { base.AddObject("Services", service); }