Beispiel #1
0
        public static bool Save(Entities.Tour tour)
        {
            bool res = false;

            try
            {
                if (tour.IsDirty)
                {
                    if (tour.Id < 0)
                    {
                        res = toursRepo.Insert(tour);

                        if (!cache.Contains(tour) &&
                            (tour.Time.Value.Date - cache.Time.Date).Days == 0)
                        {
                            InsertInCache(tour);
                        }
                    }
                    else
                    {
                        res = toursRepo.Update(tour);

                        if (cache.Contains(tour) &&
                            (tour.Time.Value.Date - cache.Time.Date).Days != 0)
                        {
                            cache.Remove(tour);
                        }
                        else
                        {
                            UpdateInCache(tour);
                        }
                    }

                    if (res)
                    {
                        tour.IsDirty = false;
                    }
                }
                else
                {
                    res = true;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    DomainModel.Application.Status.Update(
                        StatusController.Abstract.StatusTypes.Error,
                        "",
                        ex.Message);
                }
                catch { }
            }

            return(res);
        }