public Company GetById(int companyId) { if (companyId < 1) { return(null); } Company company; using (IUnitOfWork uow = new UnitOfWork()) { company = uow.CompanyRepository.Find(companyId); } return(company); }
public int Update(Company company) { try { Company companyUPdate = null; using (IUnitOfWork uow = new UnitOfWork()) { companyUPdate = uow.CompanyRepository.Find(company.CompanyId); } companyUPdate.CompanyCode = company.CompanyCode; companyUPdate.CompanyName = company.CompanyName; companyUPdate.Photo = company.Photo; companyUPdate.PictureLogo = company.PictureLogo; companyUPdate.ClassId = company.ClassId; companyUPdate.TypeId = company.TypeId; companyUPdate.Address = company.Address; companyUPdate.Accountant = company.Accountant; companyUPdate.AccountantPhone = company.AccountantPhone; companyUPdate.SwiftCode = company.SwiftCode; companyUPdate.Taxcode = company.Taxcode; companyUPdate.Branch = company.Branch; companyUPdate.NumberOfEmployee = company.NumberOfEmployee; companyUPdate.Note = company.Note; companyUPdate.MainDeputy.Phone = company.MainDeputy.Phone; companyUPdate.MainDeputy.DeputyName = company.MainDeputy.DeputyName; companyUPdate.MainDeputy.Email = company.MainDeputy.Email; companyUPdate.MainDeputy.Sex = company.MainDeputy.Sex; using (IUnitOfWork uow = new UnitOfWork()) { uow.CompanyRepository.Update(company); uow.DeputyRepository.Update(company.MainDeputy); uow.Commit(); } return(0); } catch { return(-1); } }
public bool Delete(string companyId) { if (string.IsNullOrEmpty(companyId)) { return(false); } bool resulf; using (var uow = new UnitOfWork()) { try { uow.CompanyRepository.InActive(int.Parse(companyId)); uow.Commit(); resulf = true; } catch (Exception) { resulf = false; } } return(resulf); }
public bool Delete(Company company) { if (company == null) { return(false); } var resulf = false; using (var uow = new UnitOfWork()) { try { uow.CompanyRepository.InActive(company); uow.Commit(); resulf = true; } catch (Exception) { resulf = false; } } return(resulf); }