Пример #1
0
        public string ToggleNotifSetting(UserModel user, string text)
        {
            long   stId = long.Parse(text);
            string res  = GetStationName(stId);

            using (var dataModel = new Mibarim_plusEntities())
            {
                var notif =
                    dataModel.PassNotifs.FirstOrDefault(x => x.UserId == user.TuserId && x.StationRouteId == stId);
                if (notif != null)
                {
                    res += notif.NotifStatus == (int)NotifStatus.On ? " خاموش " : " روشن ";
                    notif.NotifStatus = notif.NotifStatus == (int)NotifStatus.On
                        ? (int)NotifStatus.Off
                        : (int)NotifStatus.On;
                }
                else
                {
                    var passNotif = new PassNotif();
                    passNotif.UserId         = user.TuserId;
                    passNotif.StationRouteId = stId;
                    passNotif.CreateTime     = DateTime.Now;
                    passNotif.NotifStatus    = (int)NotifStatus.On;
                    dataModel.PassNotifs.Add(passNotif);
                    res += " روشن ";
                }
                dataModel.SaveChanges();
            }
            return(res);
        }
Пример #2
0
        public void SetNotifSettingOn(UserModel user, string text)
        {
            var stationRouteId = GetStationRouteId(text);

            using (var dataModel = new Mibarim_plusEntities())
            {
                var notif =
                    dataModel.PassNotifs.FirstOrDefault(
                        x => x.UserId == user.TuserId && x.StationRouteId == stationRouteId);
                if (notif == null)
                {
                    var passNotif = new PassNotif();
                    passNotif.UserId         = user.TuserId;
                    passNotif.StationRouteId = stationRouteId;
                    passNotif.CreateTime     = DateTime.Now;
                    passNotif.NotifStatus    = (int)NotifStatus.On;
                    dataModel.PassNotifs.Add(passNotif);
                    dataModel.SaveChanges();
                }
            }
        }