Пример #1
0
        public BaseViewModel GetItem(int itemId)
        {
            var item = new BaseViewModel();

            using (dbConn)
            {
                var _item = (dbConn.Table<MSPCrew>().Where(c => c.Id == itemId)).Single();
                item.Id = _item.Id;
                item.Name = _item.Name;
                item.Campus = _item.Campus;
            }
            return item;
        }
Пример #2
0
        public string SaveItem(BaseViewModel item)
        {
            string result = string.Empty;
            int success;

            using (dbConn)
            {
                try
                {
                    var existingItem = (dbConn.Table<MSPCrew>().Where(c => c.Id == item.Id)).SingleOrDefault();
                    if (existingItem != null)
                    {
                        existingItem.Name = item.Name;
                        success = dbConn.Update(existingItem);
                    }
                    else
                    {
                        success = dbConn.Insert(new MSPCrew()
                        {
                            Name = item.Name,
                            Campus = item.Campus
                        });
                    }
                    result = "Success";
                }
                catch
                {
                    result = "This item was not saved";
                }
            }
            return result;
        }