示例#1
0
 public ItemType VDeleteObject(ItemType itemType, IItemService _itemService, IMaintenanceService _maintenanceService)
 {
     VHasMaintenance(itemType, _maintenanceService);
     if (itemType.Errors.Any()) { return itemType; }
     VHasItem(itemType, _itemService);
     return itemType;
 }
示例#2
0
 public ItemType VHasMaintenance(ItemType itemType, IMaintenanceService _maintenanceService)
 {
     IList<Maintenance> list = _maintenanceService.GetObjectsByItemTypeId(itemType.Id);
     if (list.Any())
     {
         itemType.Errors.Add("Maintenance", "Tidak boleh ada yang terasosiakan dengan itemType");
     }
     return itemType;
 }
示例#3
0
 public ItemType VHasItem(ItemType itemType, IItemService _itemService)
 {
     IList<Item> list = _itemService.GetObjectsByItemTypeId(itemType.Id);
     if (list.Any())
     {
         itemType.Errors.Add("Item", "Tidak boleh ada yang terasosiakan dengan itemType");
     }
     return itemType;
 }
示例#4
0
 public ItemType CreateObject(string Name, string Description)
 {
     ItemType itemType = new ItemType
     {
         Name = Name,
         Description = Description
     };
     return this.CreateObject(itemType);
 }
示例#5
0
 public string PrintError(ItemType obj)
 {
     string erroroutput = "";
     KeyValuePair<string, string> first = obj.Errors.ElementAt(0);
     erroroutput += first.Key + "," + first.Value;
     foreach (KeyValuePair<string, string> pair in obj.Errors.Skip(1))
     {
         erroroutput += Environment.NewLine;
         erroroutput += pair.Key + "," + pair.Value;
     }
     return erroroutput;
 }
示例#6
0
 internal static String SaveData(FormCollection isi)
 {
     ItemType ItemType = new ItemType();
     ItemType.Name = isi["TxtName"];
     ItemType.Description = isi["TxtDescription"];
     ItemTypeModel p = new ItemTypeModel();
     ItemType ItemTypeNew = p.itemTypeService.CreateObject(ItemType);
     String err = (ItemTypeNew.Errors.Any()) ? p.itemTypeService.GetValidator().PrintError(ItemTypeNew) : "";
     return err;
 }
示例#7
0
 public ItemType VName(ItemType itemType, IItemTypeService _itemTypeService)
 {
     if (String.IsNullOrEmpty(itemType.Name) || itemType.Name.Trim() == "")
     {
         itemType.Errors.Add("Name", "Tidak boleh kosong");
     }
     if (_itemTypeService.IsNameDuplicated(itemType))
     {
         itemType.Errors.Add("Name", "Tidak boleh diduplikasi");
     }
     return itemType;
 }
示例#8
0
 public ItemType VCreateObject(ItemType itemType, IItemTypeService _itemTypeService)
 {
     VName(itemType, _itemTypeService);
     return itemType;
 }
示例#9
0
 public bool ValidUpdateObject(ItemType itemType, IItemTypeService _itemTypeService)
 {
     itemType.Errors.Clear();
     VUpdateObject(itemType, _itemTypeService);
     return isValid(itemType);
 }
示例#10
0
 public bool ValidDeleteObject(ItemType itemType, IItemService _itemService, IMaintenanceService _maintenanceService)
 {
     itemType.Errors.Clear();
     VDeleteObject(itemType, _itemService, _maintenanceService);
     return isValid(itemType);
 }
示例#11
0
 public bool ValidCreateObject(ItemType itemType, IItemTypeService _itemTypeService)
 {
     VCreateObject(itemType, _itemTypeService);
     return isValid(itemType);
 }
示例#12
0
 public bool isValid(ItemType obj)
 {
     bool isValid = !obj.Errors.Any();
     return isValid;
 }
示例#13
0
 public ItemType UpdateObject(ItemType itemType)
 {
     return (itemType = _validator.ValidUpdateObject(itemType, this) ? _repository.UpdateObject(itemType) : itemType);
 }
示例#14
0
 public ItemType SoftDeleteObject(ItemType itemType, IItemService _itemService, IMaintenanceService _maintenanceService)
 {
     return (itemType = _validator.ValidDeleteObject(itemType, _itemService, _maintenanceService) ? _repository.SoftDeleteObject(itemType) : itemType);
 }
示例#15
0
 public bool IsNameDuplicated(ItemType itemType)
 {
     IQueryable<ItemType> types = _repository.FindAll(x => x.Name == itemType.Name && !x.IsDeleted && x.Id != itemType.Id);
     return (types.Count() > 0 ? true : false);
 }
示例#16
0
 public ItemType CreateObject(ItemType itemType)
 {
     itemType.Errors = new Dictionary<String, String>();
     return (_validator.ValidCreateObject(itemType, this) ? _repository.CreateObject(itemType) : itemType);
 }