コード例 #1
0
        /// <summary>
        /// Used to edit a timeZone Entry
        /// </summary>
        /// <returns></returns>
        public int ModifyTimeZoneEntry(TimeZoneEntry entry)
        {
            try
            {
                using (var tde = new TimeDifferenceEntities())
                {
                    var timeZoneEntry =
                        tde.TimeZoneEntries.FirstOrDefault(m => m.IsActive && m.Id == entry.Id);

                    if (timeZoneEntry == null)
                        return -1;
                    timeZoneEntry.City = entry.City;
                    timeZoneEntry.Difference = entry.Difference;
                    timeZoneEntry.EntryName = entry.EntryName;
                    tde.SaveChanges();
                    return timeZoneEntry.Id;
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Exception Occured", ex.InnerException);
            }
        }
コード例 #2
0
        /// <summary>
        /// Used to save a timeZone Entry
        /// </summary>
        /// <returns></returns>
        public int SaveNewTimeZoneEntry(TimeZoneEntry entry)
        {
            try
            {
                using (var tde = new TimeDifferenceEntities())
                {
                    tde.TimeZoneEntries.Add(entry);
                    tde.SaveChanges();
                    return entry.Id;
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Exception Occured", ex.InnerException);
            }
        }