Example #1
0
 public Agency selectAgency(Agency obj)
 {
     try
     {
         IAgencySvc svc = (IAgencySvc)this.getService(typeof(IAgencySvc).Name);
         return svc.selectAgency(obj);
     }
     catch (ServiceLoadException ex)
     {
         throw ex;
     }
 }
Example #2
0
        public Boolean objectDataEquals(Agency obj)
        {
            if (!(this.Agency_ID.Equals(obj.Agency_ID)))
            {
                return false;
            }
            if (!(this.Agency_Name.Equals(obj.Agency_Name)))
            {
                return false;
            }

            return true;
        }
Example #3
0
 public Boolean deleteAgency(Agency obj)
 {
     try
     {
         IAgencySvc svc = (IAgencySvc)this.getService(typeof(IAgencySvc).Name);
         return svc.deleteAgency(obj);
     }
     catch (ServiceLoadException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw new BusinessValidationException(CustomErrors.ROW_DELETED_ERROR);
     }
 }
Example #4
0
        public bool deleteAgency(Agency obj)
        {
            using (RealReportContext db = new RealReportContext())
            {
                try
                {
                    IQueryable<Agency> AgencyList = from agency in db.Agencies
                                                        where agency.Agency_ID == obj.Agency_ID
                                                        select agency;

                    if ((AgencyList.ToArray().Length > 0))
                    {
                        foreach (Agency agency in AgencyList.ToList())
                        {
                            for (int n = 0; n < agency.Agents.Count; n++)
                            {
                                db.Agents.Remove((agency.Agents.ToArray())[0]);
                            }
                        }

                        db.Agencies.Remove((AgencyList.ToArray())[0]);

                        #region Database Submission

                        try
                        {
                            db.SaveChanges();
                            return true;
                        }
                        catch (Exception ex)
                        {
                            return false;
                        }

                        #endregion
                    }
                    else
                    {
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }
Example #5
0
        public Agency selectAgency(Agency obj)
        {
            RealReportContext db = new RealReportContext();

            try
            {
                IQueryable<Agency> AgencyList = from agency in db.Agencies
                                                    where agency.Agency_ID == obj.Agency_ID
                                                    select agency;

                return (AgencyList.ToList())[0];
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Example #6
0
        public bool insertAgency(Agency obj)
        {
            using (RealReportContext db = new RealReportContext())
            {
                try
                {
                    db.Agencies.Add(obj);
                    db.SaveChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }

            }
        }
Example #7
0
 public Boolean updateAgency(Agency obj)
 {
     try
     {
         IAgencySvc svc = (IAgencySvc)this.getService(typeof(IAgencySvc).Name);
         if (obj.isDataEntered())
         {
             return svc.updateAgency(obj);
         }
         else
         {
             throw new BusinessValidationException(CustomErrors.REQUIRED_FIELD);
         }
     }
     catch (ServiceLoadException ex)
     {
         throw ex;
     }
 }
Example #8
0
        public bool updateAgency(Agency obj)
        {
            using (RealReportContext db = new RealReportContext())
            {
                try
                {

                    IQueryable<Agency> AgencyList = from agency in db.Agencies
                                                        where agency.Agency_ID == obj.Agency_ID
                                                        select agency;

                    if ((AgencyList.ToArray()).Length > 0)
                    {
                        foreach (Agency agency in AgencyList)
                        {
                            agency.Agency_Name = obj.Agency_Name;

                        }

                        #region Database Submission with Rollback

                        try
                        {
                            db.SaveChanges();
                            return true;
                        }
                        catch (Exception ex)
                        {
                            return false;
                        }
                        #endregion
                    }
                    else
                    {
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }

            }
        }