示例#1
0
        public override void EditList(Noti item, EditType type)
        {
            switch (type)
            {
            case EditType.Add:
                item.NotiId = IdPreIndex + Notis.Count;

                Notis.Add(item);
                Notis.Sort(SortNotis);
                break;

            case EditType.Remove:
                Notis.Remove(Notis.Find(x => x.NotiId == item.NotiId));
                break;

            case EditType.Edit:
                int index = Notis.FindIndex(x => x.NotiId == item.NotiId);

                Notis[index] = item;
                Notis[index].UpdateTime();
                break;

            case EditType.EditOnlyTime:
                Notis[Notis.FindIndex(x => x.NotiId == item.NotiId)] = item;
                break;

            default:
                break;
            }

            SaveNotis();
            UpdateScheduledNoti <GardeningNoti>();
        }
        public IHttpActionResult PutNotis(int id, Notis notis)
        {
            if (!ModelState.IsValid)
            {
                Logger.Error("Fel format på angivna data");
                return(BadRequest(ModelState));
            }

            if (id != notis.Id)
            {
                Logger.Error("Gick inte att hitta notis med id:t");
                return(BadRequest());
            }

            db.Entry(notis).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NotisExists(id))
                {
                    Logger.Error("Notisen finns inte");
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public override void EditList(Noti item, EditType type)
        {
            var noti = item as RealmFriendshipNoti;

            switch (type)
            {
            case EditType.Add:
                if (Notis.FindAll(x => (x as RealmFriendshipNoti).Percentage.Equals(noti.Percentage)).Count == 0)
                {
                    Notis.Add(item);
                    Notis.Sort(SortNotis);
                }
                else
                {
                    DependencyService.Get <IToast>().Show(AppResources.NotiSettingPage_AlreadyExistToast_Message);
                }
                break;

            case EditType.Remove:
                Notis.Remove(Notis.Find(x => (x as RealmFriendshipNoti).Percentage.Equals(noti.Percentage)));
                break;

            case EditType.Edit:
                (Notis[Notis.FindIndex(x => (x as RealmFriendshipNoti).Percentage.Equals(noti.Percentage))] as RealmFriendshipNoti).Percentage = noti.Percentage;
                break;

            default:
                break;
            }

            SaveNotis();
            UpdateScheduledNoti <RealmFriendshipNoti>();
        }
示例#4
0
        public override void EditList(Noti item, EditType type)
        {
            switch (type)
            {
            case EditType.Add:
                item.NotiId = ID_PREINDEX + Notis.Count;

                Notis.Add(item);
                Notis.Sort(SortNotis);
                break;

            case EditType.Remove:
                Notis.Remove(Notis.Find(x => x.NotiId.Equals(item.NotiId)));
                break;

            case EditType.Edit:
                var index = Notis.FindIndex(x => x.NotiId.Equals(item.NotiId));

                Notis[index] = item;
                Notis[index].UpdateTime();
                break;

            default:
                break;
            }

            SaveNotis();
            UpdateScheduledNoti <GadgetNoti>();
        }
        public IHttpActionResult GetNotis(int id)
        {
            Notis notis = db.Notis.Find(id);

            if (notis == null)
            {
                Logger.Error("Gick inte att hitta notiser");
                return(NotFound());
            }

            return(Ok(notis));
        }
        public IHttpActionResult PostNotis(Notis notis)
        {
            if (!ModelState.IsValid)
            {
                Logger.Error("Fel format på angivna data");
                return(BadRequest(ModelState));
            }

            db.Notis.Add(notis);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = notis.Id }, notis));
        }
        public RealmFriendshipNotiManager() : base()
        {
            try
            {
                NotiType = NotificationType.RealmFriendship;

                Notis.AddRange(GetNotiList <RealmFriendshipNoti>());
            }
            catch (Exception)
            {
                DependencyService.Get <IToast>().Show("Fail to initialize noti manager");
            }
        }
示例#8
0
        public ExpeditionNotiManager() : base()
        {
            try
            {
                NotiType = NotificationType.Expedition;

                Notis.AddRange(GetNotiList <ExpeditionNoti>());
            }
            catch (Exception)
            {
                DependencyService.Get <IToast>().Show("Fail to initialize expedition noti manager");
            }
        }
示例#9
0
        public GardeningNotiManager() : base()
        {
            try
            {
                NotiType = NotificationType.Gardening;

                Notis.AddRange(GetNotiList <GardeningNoti>());

                SaveNotis();
            }
            catch (Exception)
            {
                DependencyService.Get <IToast>().Show("Fail to initialize Gardening noti manager");
            }
        }
        public IHttpActionResult DeleteNotis(int id)
        {
            Notis notis = db.Notis.Find(id);

            if (notis == null)
            {
                Logger.Error("Gick inte att hitta notisen");
                return(NotFound());
            }

            db.Notis.Remove(notis);
            db.SaveChanges();

            return(Ok(notis));
        }