Exemplo n.º 1
0
        public ObservableCollection <Models.ListItem> GetAll()
        {
            var db   = this.conn;
            var view = new ObservableCollection <Models.ListItem>();

            try
            {//UPDATE Customer SET Name = ?, City = ?, Contact = ? WHERE Id=?
                using (var statement = db.Prepare("SELECT * FROM item"))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        var temp  = ((string)statement[3]).Split('/');
                        var date1 = new DateTime(int.Parse(temp[2]), int.Parse(temp[0]), int.Parse(temp[1]));
                        var date  = new DateTimeOffset(date1);
                        var titem = new Models.ListItem((string)statement[1], (string)statement[2], date,
                                                        (string)statement[4], (string)statement[0], ((Int64)statement[5]) == Int64.Parse("1") ? true : false);
                        view.Add(titem);
                    }
                }
                return(view);
            }
            catch (Exception ex)
            {
                // TODO: Handle error
                return(view);
            }
        }
Exemplo n.º 2
0
 async public void UpdateListItem(string id, string title, string description, DateTime date, WriteableBitmap imageSource)
 {
     for (int i = 0; i < allItems.Count; ++i)
     {
         if (allItems[i].GetID() == id)
         {
             allItems[i].Title       = title;
             allItems[i].description = description;
             allItems[i].date        = date;
             allItems[i].ImageSource = imageSource;
             using (var conn = new SQLiteConnection("MyListDB.db"))
             {
                 using (var statement = conn.Prepare("UPDATE ListItemTable SET Title = ?, Detail = ?, Date = ?, Complete = ?, Image = ? WHERE Id = ?"))
                 {
                     statement.Bind(1, title);
                     statement.Bind(2, description);
                     statement.Bind(3, date.ToString());
                     statement.Bind(4, allItems[i].Completed.ToString());
                     statement.Bind(5, await ImageTools.SaveToBytesAsync(allItems[i].ImageSource));
                     statement.Bind(6, id);
                     statement.Step();
                 }
             }
         }
     }
     selectedItem = null;
 }
Exemplo n.º 3
0
        private ListItemViewModels()
        {
            selectedItem = null;
            var db = App.conn;

            using (var statement = db.Prepare(App.SQL_QUERY_VALUE))
            {
                while (SQLitePCL.SQLiteResult.ROW == statement.Step())
                {
                    this.allItems.Add(new Models.ListItem(statement[0].ToString(), statement[1].ToString(),
                                                          Convert.ToDateTime(statement[2].ToString()), Convert.ToBoolean(statement[3].ToString()),
                                                          statement[4].ToString(), Convert.ToInt32(statement[5])));
                }
            }

            /*
             * ImageSource imgSource1 = new BitmapImage(new Uri("ms-appx:///Assets/Pics/1.jpg"));
             * ImageSource imgSource2 = new BitmapImage(new Uri("ms-appx:///Assets/Pics/2.jpg"));
             * ImageSource imgSource3 = new BitmapImage(new Uri("ms-appx:///Assets/Pics/3.jpg"));
             * ImageSource imgSource4 = new BitmapImage(new Uri("ms-appx:///Assets/Pics/4.jpg"));
             * Models.ListItem item1 = new Models.ListItem("数据结构", "Data Structure", DateTime.Now, imgSource1);
             * item1.completed = true;
             * Models.ListItem item2 = new Models.ListItem("现代操作系统应用开发", "MOSAD", DateTime.Now, imgSource2);
             * allItems.Add(item1);
             * allItems.Add(item2);
             * allItems.Add(new Models.ListItem("操作系统(OS)", "Opreation System", DateTime.Now, imgSource3));
             * allItems.Add(new Models.ListItem("计算机组成原理与接口技术", "Computer Organization and Design", DateTime.Now, imgSource4));
             */
        }
Exemplo n.º 4
0
 private async Task ClearFilter()
 {
     competenceArea = competenceAreas.FirstOrDefault();
     availableFrom  = null;
     organization   = organizations.FirstOrDefault();
     await UpdateFilter();
 }
Exemplo n.º 5
0
 private ListItemViewModels()
 {
     allItems     = Db.GetInstance().GetAll();
     seleted      = false;
     editing_item = new Models.ListItem();
     seleteItem   = -1;
 }
Exemplo n.º 6
0
        public IHttpActionResult PutListItem(int id, Models.ListItem listItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != listItem.ListItemID)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ListItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 7
0
        public UpdateResult SetActiveStatus(string id, bool active, string lastUpdateUsername)
        {
            return(Execute(context =>
            {
                Guid lastUpdateAccountId = context.Accounts.Single(a => a.Username == lastUpdateUsername).AccountId;

                Guid accountId = BaseModel.DecryptId(id);

                if (lastUpdateAccountId == accountId)
                {
                    return new UpdateResult("Cannot update your own status");
                }

                Models.ListItem listItem = DataAccess.ListItem.GetListItem("Status", active ? "Active" : "InActive");

                Data.Account account = context.Accounts.Single(acc => acc.AccountId == accountId);

                account.StatusId = listItem.GUID;

                WriteAudit(context, lastUpdateAccountId);
                account.LastUpdateAccountId = account.AccountId;
                account.LastUpdateTimestamp = DateTime.Now;

                context.SaveChanges();

                return new UpdateResult(true);
            }));
        }
Exemplo n.º 8
0
 public void UpdateListItem(ImageSource img, double size, string title, string detail, DateTimeOffset date)
 {
     this.selectedItem.Img    = img;
     this.selectedItem.Size   = size;
     this.selectedItem.Title  = title;
     this.selectedItem.Detail = detail;
     this.selectedItem.Date   = date;
     this.selectedItem        = null;
 }
Exemplo n.º 9
0
        public IHttpActionResult GetListItem(int id)
        {
            Models.ListItem listItem = db.ListItems.Find(id);
            if (listItem == null)
            {
                return(NotFound());
            }

            return(Ok(listItem));
        }
Exemplo n.º 10
0
 public void RemoveTodoItem(string id)
 {
     for (int i = 0; i < allItems.Count; i++)
     {
         if (allItems[i].id == id)
         {
             this.allItems.RemoveAt(i);
         }
     }
     // set selectedItem to null after remove
     this.selectedItem = null;
 }
Exemplo n.º 11
0
        public IHttpActionResult PostListItem(Models.ListItem listItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ListItems.Add(listItem);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = listItem.ListItemID }, listItem));
        }
Exemplo n.º 12
0
        public IHttpActionResult DeleteListItem(int id)
        {
            Models.ListItem listItem = db.ListItems.Find(id);
            if (listItem == null)
            {
                return(NotFound());
            }

            db.ListItems.Remove(listItem);
            db.SaveChanges();

            return(Ok(listItem));
        }
Exemplo n.º 13
0
 public void UpdateTodoItem(string id, string title, string description, DateTime date, ImageSource img)
 {
     for (int i = 0; i < allItems.Count; i++)
     {
         if (allItems[i].id == id)
         {
             allItems[i].title       = title;
             allItems[i].description = description;
             allItems[i].date        = date;
             allItems[i].img         = img;
             break;
         }
     }
     // set selectedItem to null after update
     this.selectedItem = null;
 }
Exemplo n.º 14
0
        public Models.UpdateResult SaveListItem(Models.ListItem model)
        {
            return(Execute(context =>
            {
                Guid lastUpdateAccountId = context.Accounts.Single(a => a.Username == model.LastUpdateUsername).AccountId;
                Data.ListItem listItem;
                if (!string.IsNullOrEmpty(model.ID))
                {
                    Guid listItemId = BaseModel.DecryptId(model.ID);
                    listItem = context.ListItems.Single(li => li.ListItemId == listItemId);

                    if (listItem.LastUpdateTimestamp.Ticks != model.Age)
                    {
                        return new UpdateResult(UpdateResult.ResultType.DataChanged);
                    }
                }
                else
                {
                    listItem = new Data.ListItem
                    {
                        ParentId = BaseModel.DecryptNullableId(model.ParentID),
                        StatusId = GetListItem("Status", "Active").GUID
                    };
                    context.ListItems.Add(listItem);
                }

                if (!string.IsNullOrWhiteSpace(model.Name))
                {
                    listItem.Name = model.Name;
                }

                listItem.Description = model.Description;
                listItem.SortOrder = model.SortOrder;
                listItem.Code = model.Code;
                listItem.Value = model.Value;

                WriteAudit(context, lastUpdateAccountId);

                listItem.LastUpdateAccountId = lastUpdateAccountId;
                listItem.LastUpdateTimestamp = DateTime.Now;

                context.SaveChanges();

                return new UpdateResult(true);
            }));
        }
Exemplo n.º 15
0
        async public void AddListItem(string title, string description, DateTime date, WriteableBitmap imageSource)
        {
            ListItem item = new Models.ListItem(title, description, date, imageSource);

            this.allItems.Add(item);
            using (var conn = new SQLiteConnection("MyListDB.db"))
            {
                using (var statement = conn.Prepare("INSERT INTO ListItemTable (Id, Title, Detail, Date, Complete, Image) VALUES (?, ?, ?, ?, ?, ?)"))
                {
                    statement.Bind(1, item.GetID());
                    statement.Bind(2, title);
                    statement.Bind(3, description);
                    statement.Bind(4, date.ToString());
                    statement.Bind(5, item.Completed.ToString());
                    statement.Bind(6, await ImageTools.SaveToBytesAsync(item.ImageSource));
                    statement.Step();
                }
            }
        }
Exemplo n.º 16
0
 public void RemoveListItem(string id)
 {
     for (int i = 0; i < allItems.Count; ++i)
     {
         if (allItems[i].GetID() == id)
         {
             using (var conn = new SQLiteConnection("MyListDB.db"))
             {
                 using (var statement = conn.Prepare("DELETE FROM ListItemTable WHERE Id = ?"))
                 {
                     statement.Bind(1, id);
                     statement.Step();
                 }
             }
             allItems.RemoveAt(i); break;
         }
     }
     selectedItem = null;
 }
Exemplo n.º 17
0
        /*public static XmlDocument CreateTiles(Models.ListItem item)
         * {
         *  XDocument xDoc = new XDocument(
         *      new XElement("tile", new XAttribute("version", 3),
         *          new XElement("visual",
         *              // Small Tile
         *              new XElement("binding", new XAttribute("branding", "none"),
         *                  new XAttribute("displayName", "qqq"), new XAttribute("template", "TileSmall")
         *                  ),
         *
         *              // Medium Tile
         *              new XElement("binding", new XAttribute("branding", "name"),
         *                  new XAttribute("displayName", "www"), new XAttribute("template", "TileMedium"),
         *                  new XElement("group",
         *                      new XElement("subgroup",
         *                          new XElement("text", item.Plan_date, new XAttribute("hint-style", "caption")),
         *                          new XElement("text", item.Title,
         *                              new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true),
         *                              new XAttribute("hint-maxLines", 3))
         *                          )
         *                      )
         *                  ),
         *
         *              // Wide Tile
         *              new XElement("binding", new XAttribute("branding", "name"),
         *                  new XAttribute("displayName", "eee"), new XAttribute("template", "TileWide"),
         *                  new XElement("group",
         *                      new XElement("subgroup",
         *                          new XElement("text", item.Plan_date, new XAttribute("hint-style", "caption")),
         *                          new XElement("text", item.Title,
         *                              new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true),
         *                              new XAttribute("hint-maxLines", 3)),
         *                          new XElement("text", item.Content,
         *                              new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true),
         *                              new XAttribute("hint-maxLines", 3))
         *                          ),
         *                      new XElement("subgroup", new XAttribute("hint-weight", 15),
         *                          new XElement("image", new XAttribute("placement", "inline"),
         *                              new XAttribute("src", "Assets/StoreLogo.png"))
         *                          )
         *                      )
         *                  ),
         *
         *              //Large Tile
         *              new XElement("binding", new XAttribute("branding", "title"),
         *                  new XAttribute("displayName", "rrr"), new XAttribute("template", "TileLarge"),
         *                  new XElement("group",
         *                      new XElement("subgroup",
         *                          new XElement("text", item.Plan_date, new XAttribute("hint-style", "caption")),
         *                          new XElement("text", item.Title,
         *                              new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true),
         *                              new XAttribute("hint-maxLines", 3)),
         *                          new XElement("text", item.Content,
         *                              new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true),
         *                              new XAttribute("hint-maxLines", 3))
         *                          ),
         *                      new XElement("subgroup", new XAttribute("hint-weight", 15),
         *                          new XElement("image", new XAttribute("placement", "inline"),
         *                              new XAttribute("src", "Assets/StoreLogo.png"))
         *                          )
         *                      )
         *                  )
         *              )
         *          )
         *      );
         *
         *  XmlDocument xmlDoc = new XmlDocument();
         *  xmlDoc.LoadXml(xDoc.ToString());
         *  //Debug.WriteLine(xDoc);
         *  return xmlDoc;
         * }*/

        public static void Update(Models.ListItem item)
        {
            // In a real app, these would be initialized with actual data
            string time    = item.Plan_date.ToString();
            string subject = item.Title;
            string body    = item.Content;


            // Construct the tile content
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = "Assets/StoreLogo.png"
                            },

                            Children =
                            {
                            }
                        }
                    },

                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = item.ImagePath
                            },

                            Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = subject
                                },

                                new AdaptiveText()
                                {
                                    Text      = body,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                                },

                                new AdaptiveText()
                                {
                                    Text      = time,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                                }
                            }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = item.ImagePath
                            },

                            Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = subject
                                },

                                new AdaptiveText()
                                {
                                    Text      = body,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                                },

                                new AdaptiveText()
                                {
                                    Text      = time,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                                }
                            }
                        }
                    }
                }
            };


            // Then create the tile notification
            var notification = new TileNotification(content.GetXml());


            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            // And send the notification
            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
Exemplo n.º 18
0
        private async Task OnInitialize()
        {
            try
            {
                var foo = Mapper.ProjectTo <Models.ListItem>((
                                                                 await CompetenceAreasClient.GetCompetenceAreasAsync()).AsQueryable()).ToList();

                foo.Insert(0, new Models.ListItem()
                {
                    Id = null, Name = "All"
                });

                competenceAreas = foo;

                competenceArea = competenceAreas.FirstOrDefault();
            }

            /* catch (ApiException exc)
             * {
             * }
             * catch (HttpRequestException exc)
             * {
             * } */
            catch (Exception exc)
            {
                await JSHelpers.Alert(exc.Message);
            }

            try
            {
                var foo = Mapper.ProjectTo <Models.ListItem>((
                                                                 await OrganizationsClient.GetOrganizationsAsync()).AsQueryable()).ToList();

                foo.Insert(0, new Models.ListItem()
                {
                    Id = null, Name = "All"
                });

                organizations = foo;

                organization = organizations.FirstOrDefault();
            }

            /*catch (ApiException exc)
             * {
             *
             * }
             * catch (HttpRequestException exc)
             * {
             *
             * }*/
            catch (Exception exc)
            {
                await JSHelpers.Alert(exc.Message);
            }

            try
            {
                var result = await ConsultantGalleryClient.GetConsultantsAsync(pageNumber ++, numberOfItemsPerPage, null, null, null);

                consultants = new List <ProfileShort>();
                consultants.AddRange(result.Items);
                total = result.TotalItems;
            }

            /*catch (ApiException exc)
             * {
             *
             * }
             * catch (HttpRequestException exc)
             * {
             *
             * }*/
            catch (Exception exc)
            {
                await JSHelpers.Alert(exc.Message);
            }
        }
Exemplo n.º 19
0
 public void RemoveListItem(Models.ListItem SelectedItem1)
 {
     this.allItems.Remove(SelectedItem1);
     this.selectedItem = null;
 }
Exemplo n.º 20
0
 public ListItemViewModel()
 {
     this.selectedItem = null;
 }