Пример #1
0
 public Country selectCountry(Country obj)
 {
     try
     {
         ICountrySvc svc = (ICountrySvc)this.getService(typeof(ICountrySvc).Name);
         return svc.selectCountry(obj);
     }
     catch (ServiceLoadException ex)
     {
         throw ex;
     }
 }
Пример #2
0
        public Boolean objectDataEquals(Country obj)
        {
            if (!(this.Country_ID.Equals(obj.Country_ID)))
            {
                return false;
            }
            if (!(this.Country_Name.Equals(obj.Country_Name)))
            {
                return false;
            }

            return true;
        }
Пример #3
0
        public bool deleteCountry(Country obj)
        {
            using (RealReportContext db = new RealReportContext())
            {
                try
                {
                    IQueryable<Country> CountryList = from country in db.Countries
                                                      where country.Country_ID == obj.Country_ID
                                                      select country;

                    if ((CountryList.ToArray().Length > 0))
                    {

                        foreach (Country country in CountryList)
                        {
                            for (int n = 0; n < country.Locations.Count; n++)
                            {
                                db.Locations.Remove((country.Locations.ToArray())[0]);
                            }
                        }

                        db.Countries.Remove((CountryList.ToArray())[0]);
                        #region Database Submission

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

                        #endregion
                    }
                    else
                    {
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }
Пример #4
0
        public bool insertCountry(Country obj)
        {
            using (RealReportContext db = new RealReportContext())
            {
                try
                {
                    db.Countries.Add(obj);
                    db.SaveChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }

            }
        }
Пример #5
0
 public Boolean updateCountry(Country obj)
 {
     try
     {
         ICountrySvc svc = (ICountrySvc)this.getService(typeof(ICountrySvc).Name);
         if (obj.isDataEntered())
         {
             return svc.updateCountry(obj);
         }
         else
         {
             throw new BusinessValidationException(CustomErrors.REQUIRED_FIELD);
         }
     }
     catch (ServiceLoadException ex)
     {
         throw ex;
     }
 }
Пример #6
0
        public Country selectCountry(Country obj)
        {
            RealReportContext db = new RealReportContext();

            try
            {
                IQueryable<Country> CountryList = from country in db.Countries
                                                  where country.Country_ID == obj.Country_ID
                                                  select country;

                return (CountryList.ToList())[0];
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Пример #7
0
        public bool updateCountry(Country obj)
        {
            using (RealReportContext db = new RealReportContext())
            {
                try
                {

                    IQueryable<Country> CountryList = from country in db.Countries
                                                      where country.Country_ID == obj.Country_ID
                                                      select country;

                    if ((CountryList.ToArray()).Length > 0)
                    {
                        foreach (Country country in CountryList)
                        {
                            country.Country_Name = obj.Country_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;
                }

            }
        }