示例#1
0
        public void DepartmentCreationService(int compId, string depName) // api
        {
            Lk_Company_Department cd = new Lk_Company_Department();

            cd.CompanyId      = compId;
            cd.DepartmentName = depName;
            compDepRep.AddCompanyDepartment(cd);
        }
 public bool DeleteCompanyDepartment(Lk_Company_Department companyDepartment)
 {
     try
     {
         db.CompanyDepartments.Remove(companyDepartment);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
        public bool EditCompanyDepartment(int compId, string oldDepName, string newDepName)
        {
            try
            {
                var cd = db.CompanyDepartments.Find(compId, oldDepName);
                db.CompanyDepartments.Remove(cd);
                db.SaveChanges();

                Lk_Company_Department cd2 = new Lk_Company_Department();
                cd2.CompanyId      = compId;
                cd2.DepartmentName = newDepName;
                db.CompanyDepartments.Add(cd2);
                db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }