Exemplo n.º 1
0
        private TblLkpDirectionLink UpdateOrDeleteTblDirectionLink(TblLkpDirectionLink newRow, bool save)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                if (save)
                {
                    context.TblLkpDirectionLinks.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblLkpDirectionLinks
                                  where e.TblLkpBrandSection == newRow.TblLkpBrandSection &&
                                  e.TblBrand == newRow.TblBrand &&
                                  e.TblLkpDirection == newRow.TblLkpDirection

                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        context.DeleteObject(oldRow);
                    }
                }
                context.SaveChanges();
                return(newRow);
            }
        }
Exemplo n.º 2
0
        private int FamilyCategory_UpdateOrDeleteTblLkpDirectionLink(string brand, int section, int direction, bool save)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                if (save)
                {
                    TblLkpDirectionLink newRow = new TblLkpDirectionLink();
                    newRow.TblBrand           = brand;
                    newRow.TblLkpBrandSection = section;
                    newRow.TblLkpDirection    = direction;
                    context.TblLkpDirectionLinks.AddObject(newRow);
                }
                else
                {
                    //Delete From TblLkpdirectionLink
                    var oldDirectionRow = (from e in context.TblLkpDirectionLinks
                                           where e.TblLkpBrandSection == section &&
                                           e.TblBrand == brand && e.TblLkpDirection == direction
                                           select e).SingleOrDefault();

                    if (oldDirectionRow != null)
                    {
                        context.DeleteObject(oldDirectionRow);
                    }
                    context.SaveChanges();

                    //Delete From TblLkpstyleCategoryLink
                    var oldCategoryRow = (from e in context.TblStyleCategoryLinks
                                          where e.TblLkpBrandSection == section &&
                                          e.TblBrand == brand && e.TblLkpDirection == direction
                                          select e);

                    foreach (var row in oldCategoryRow)
                    {
                        if (row != null)
                        {
                            context.DeleteObject(row);
                        }
                    }
                    context.SaveChanges();

                    //Delete From TblLkpFamilyCategoryLink
                    var oldFamilyRow = (from e in context.TblFamilyCategoryLinks
                                        where e.TblLkpBrandSection == section &&
                                        e.TblBrand == brand && e.TblLkpDirection == direction
                                        select e);

                    foreach (var row in oldFamilyRow)
                    {
                        if (row != null)
                        {
                            context.DeleteObject(row);
                        }
                    }

                    context.SaveChanges();

                    //Delete From TblLkpFamilyCategoryLink
                    var oldSubFamilyRow = (from e in context.TblSubFamilyCategoryLinks
                                           where e.TblLkpBrandSection == section &&
                                           e.TblBrand == brand && e.TblLkpDirection == direction
                                           select e);

                    foreach (var row in oldSubFamilyRow)
                    {
                        if (row != null)
                        {
                            context.DeleteObject(row);
                        }
                    }
                    context.SaveChanges();
                }
                return(context.SaveChanges());
            }
        }