public static bool DeleteByService(entitiesEvolveCentral ctx, int id, bool deleteUnique)
        {
            var item = new ServiceCrmEvolutionDetailItem();

            try
            {
                DAL.ServiceCrmEvolutionItem sitem = DAL.ServiceCrmEvolution.Get(ctx, id);

                DAL.ServiceTemplateCrmEvolutionItem stitem = DAL.ServiceTemplateCrmEvolution.Get(ctx, Convert.ToInt32(sitem.ServiceTemplateCrmEvolutionId));

                List <DAL.ServiceCrmEvolutionDetailItem> detailitems = DAL.ServiceCrmEvolutionDetail.GetByService(ctx, id);
                for (int i = 0; i < detailitems.Count; i++)
                {
                    int detailid = detailitems[i].Id;
                    DAL.ServiceCrmEvolutionDetailItem sditem = ctx.ServiceCrmEvolutionDetailItems.Find(detailid);
                    if (deleteUnique)
                    {
                        ctx.ServiceCrmEvolutionDetailItems.Remove(sditem);
                    }
                    else
                    {
                        if (!Convert.ToBoolean(sditem.IsUnique))
                        {
                            ctx.ServiceCrmEvolutionDetailItems.Remove(sditem);
                        }
                    }
                }
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
        public static ServiceCrmEvolutionDetailItem Get(entitiesEvolveCentral ctx, int id)
        {
            var item = new ServiceCrmEvolutionDetailItem();

            item = (from i in ctx.ServiceCrmEvolutionDetailItems where i.Id == id orderby i.Name ascending select i).FirstOrDefault();
            return(item);
        }
        public static bool Delete(entitiesEvolveCentral ctx, ServiceCrmEvolutionDetailItem item)
        {
            bool retval = true;

            try
            {
                ctx.ServiceCrmEvolutionDetailItems.Remove(item);
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                ApplicationLog.Log(ctx, "DAL.ServiceCrmEvolutionDetail.Delete(entitiesEvolveCentral ctx, ServiceCrmEvolutionDetailItem item)", ex.Message);
                retval = false;
            }

            return(retval);
        }
        public static bool Save(entitiesEvolveCentral ctx, ServiceCrmEvolutionDetailItem item)
        {
            try
            {
                if (item.Id == 0)
                {
                    ctx.ServiceCrmEvolutionDetailItems.Add(item);
                }

                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }