public int Save(DataContext dc, Domain.GreenhouseUser greenhouseUser)
        {
            dc = dc ?? Conn.GetContext();
            var dbGreenhouseUser = dc.GreenhouseUsers.Where(g => g.GreenhouseUserId == greenhouseUser.ID).SingleOrDefault();
            var isNew            = false;

            if (dbGreenhouseUser == null)
            {
                dbGreenhouseUser = new GreenhouseUser();
                isNew            = true;
            }

            dbGreenhouseUser.UserId       = greenhouseUser.UserID;
            dbGreenhouseUser.GreenhouseId = greenhouseUser.GreenhouseID;

            if (isNew)
            {
                dc.GreenhouseUsers.InsertOnSubmit(dbGreenhouseUser);
            }
            dc.SubmitChanges();

            greenhouseUser.ID = dbGreenhouseUser.GreenhouseId;

            return(greenhouseUser.ID);
        }
        public void Delete(DataContext dc, Domain.GreenhouseUser greenhouseUser)
        {
            dc = dc ?? Conn.GetContext();
            var dbGreenhouseUser = dc.GreenhouseUsers.Where(g => g.GreenhouseUserId == greenhouseUser.ID).SingleOrDefault();

            if (dbGreenhouseUser == null)
            {
                return;
            }
            //dc.Greenhouses.Attach(dbGreenhouse, true);
            foreach (var section in dbGreenhouseUser.Greenhouse.Sections.Where(gu => gu.UserID == dbGreenhouseUser.UserId))
            {
                dc.Sections.DeleteOnSubmit(section);
                foreach (var task in section.Tasks)
                {
                    dc.Tasks.DeleteOnSubmit(task);
                }
            }
            dc.GreenhouseUsers.DeleteOnSubmit(dbGreenhouseUser);
            dc.SubmitChanges();
        }