Esempio n. 1
0
        public bool DeleteData(int id, string season, out Notification notification)
        {
            notification = new Notification()
            {
                Type = NotificationType.Success
            };

            try
            {
                using (PriceConfigurationEntities context = CreateContext())
                {
                    List <PriceConfiguration> dbItems = context.PriceConfiguration.Where(o => o.Season.Equals(season)).ToList();

                    if (dbItems == null || dbItems.Count == 0)
                    {
                        notification = new Notification()
                        {
                            Type    = NotificationType.Error,
                            Message = "Can not find data!"
                        };

                        return(false);
                    }

                    foreach (var dbItem in dbItems)
                    {
                        context.PriceConfiguration.Remove(dbItem);
                    }

                    context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type    = NotificationType.Error,
                    Message = ex.Message
                };

                return(false);
            }
        }
Esempio n. 2
0
        public override bool DeleteData(int id, out Notification notification)
        {
            notification = new Notification()
            {
                Type = NotificationType.Success
            };

            try
            {
                using (PriceConfigurationEntities context = CreateContext())
                {
                    PriceConfiguration dbItem = context.PriceConfiguration.FirstOrDefault(o => o.PriceConfigurationID == id);

                    if (dbItem == null)
                    {
                        notification = new Notification()
                        {
                            Type    = NotificationType.Error,
                            Message = "Can not find data!"
                        };

                        return(false);
                    }

                    context.PriceConfiguration.Remove(dbItem);
                    context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type    = NotificationType.Error,
                    Message = ex.Message
                };

                return(false);
            }
        }