Example #1
0
        public CPN_Company save(CPN_Company pCompany)
        {
            CPN_Company findedCompany = null;

            using (var context = new SILOEntities())
            {
                if (pCompany.CPN_Id != 0)
                {
                    findedCompany = context.CPN_Company.Find(pCompany.CPN_Id);
                    if (findedCompany == null)
                    {
                        findedCompany = pCompany;
                        context.CPN_Company.Add(pCompany);
                    }
                    else
                    {
                        findedCompany.CPN_Code        = pCompany.CPN_Code;
                        findedCompany.CPN_DisplayName = pCompany.CPN_DisplayName;
                        findedCompany.CPN_Description = pCompany.CPN_Description;
                    }
                    context.SaveChanges();
                }
            }
            return(findedCompany);
        }
Example #2
0
        public CPN_Company getById(long pCompanyId)
        {
            CPN_Company findedCompany = null;

            using (var context = new SILOEntities())
            {
                if (pCompanyId != 0)
                {
                    findedCompany = context.CPN_Company.Find(pCompanyId);
                }
            }
            return(findedCompany);
        }