public void DeleteJob(int JobId)
        {
            Job dbJob = dbContext.Jobs.FirstOrDefault(j => j.JobId == JobId);

            if (dbJob != null)
            {
                dbContext.Jobs.Remove(dbJob);
                dbContext.SaveChanges();
            }
        }
Example #2
0
        public Category DeleteCategory(int catId)
        {
            Category dbCat = dbContext.Categories.FirstOrDefault(c => c.CatId == catId);

            if (dbCat != null)
            {
                foreach (Job j in dbCat.Jobs)
                {
                    dbContext.Jobs.Remove(j);
                }
                dbContext.Categories.Remove(dbCat);
                dbContext.SaveChanges();
            }
            return(dbCat);
        }
 public void SaveOrg(Organization org)
 {
     if (org.OrgId == 0)
     {
         dbContext.Organizations.Add(org);
     }
     else
     {
         Organization dbOrg = dbContext.Organizations.FirstOrDefault(o => o.OrgId == org.OrgId);
         if (dbOrg != null)
         {
             dbOrg.OrgName    = org.OrgName;
             dbOrg.Address    = org.Address;
             dbOrg.Email      = org.Email;
             dbOrg.PostalCode = org.PostalCode;
             dbOrg.PhoneNo    = org.PhoneNo;
             dbOrg.Website    = org.Website;
             dbOrg.Categories = org.Categories;
         }
     }
     dbContext.SaveChanges();
 }