Example #1
0
 public static IEnumerable GetAllItem()
 {
     var db = new HardwareMaintenanceEntities();
     using (db)
     {
         ItemModel p = new ItemModel();
         IList<Item> Items = p.itemService.GetAll();
         return Items;
     }
 }
Example #2
0
        internal static string SaveDataEdit(FormCollection isi)
        {
            int id = Convert.ToInt16(isi["TxtId"]);
            ItemModel p = new ItemModel();
            Item item = p.itemService.GetObjectById(id);

            item.ItemTypeId = Int32.Parse(isi["TxtItemTypeId"]);
            item.Description = isi["TxtDescription"];
            item.WarrantyExpiryDate = Convert.ToDateTime(isi["TxtWarrantyExpiryDate"]);
            item.ManufacturedAt = Convert.ToDateTime(isi["TxtManufacturedAt"]);

            Item ItemTypeNew = p.itemService.UpdateObject(item, p.itemService, p.maintenanceService);
            String err = (ItemTypeNew.Errors.Any()) ? p.itemService.GetValidator().PrintError(ItemTypeNew) : "";
            return err;
        }
Example #3
0
        internal static String SaveData(FormCollection isi)
        {
            Item item = new Item();
            item.CustomerId = Int32.Parse(isi["CmbCustomer"]);
            item.ItemTypeId = Int32.Parse(isi["TxtItemTypeId"]);
            item.Description = isi["TxtDescription"];
            item.WarrantyExpiryDate = Convert.ToDateTime(isi["TxtWarrantyExpiryDate"]);
            item.ManufacturedAt = Convert.ToDateTime(isi["TxtManufacturedAt"]);

            ItemModel p = new ItemModel();
            Item ItemTypeNew = p.itemService.CreateObject(item, p.customerService, p.itemTypeService);

            String err = (ItemTypeNew.Errors.Any()) ? p.itemService.GetValidator().PrintError(ItemTypeNew) : "";
            return err;
        }
Example #4
0
        internal static void DataDelete(int id)
        {
            ItemModel p = new ItemModel();
            Item item = p.itemService.GetObjectById(id);

            bool userDeleted = p.itemService.DeleteObject(item.Id);
        }
Example #5
0
        public static Paging<Item> ItemPaging(int start, int limit, string sort, string dir, string filter)
        {
            ItemModel p = new ItemModel();
            List<Item> items = p.itemService.GetAll().ToList();

            if (!string.IsNullOrEmpty(filter) && filter != "*")
            {
                items.RemoveAll(item => !item.Description.ToLower().StartsWith(filter.ToLower()));
            }

            if (!string.IsNullOrEmpty(sort))
            {
                items.Sort(delegate(Item x, Item y)
                {
                    object a;
                    object b;

                    int direction = dir == "DESC" ? -1 : 1;

                    a = x.GetType().GetProperty(sort).GetValue(x, null);
                    b = y.GetType().GetProperty(sort).GetValue(y, null);

                    return CaseInsensitiveComparer.Default.Compare(a, b) * direction;
                });
            }

            if ((start + limit) > items.Count)
            {
                limit = items.Count - start;
            }

            List<Item> rangeItems = (start < 0 || limit < 0) ? items : items.GetRange(start, limit);

            return new Paging<Item>(rangeItems, items.Count);
        }
Example #6
0
 public static Item GetItem(int id)
 {
     var db = new HardwareMaintenanceEntities();
     using (db)
     {
         ItemModel p = new ItemModel();
         Item Item = p.itemService.GetObjectById(id);
         return Item;
     }
 }