public ItemType VDeleteObject(ItemType itemType, IItemService _itemService, IMaintenanceService _maintenanceService) { VHasMaintenance(itemType, _maintenanceService); if (itemType.Errors.Any()) { return itemType; } VHasItem(itemType, _itemService); return itemType; }
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; }
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; }
public ItemType CreateObject(string Name, string Description) { ItemType itemType = new ItemType { Name = Name, Description = Description }; return this.CreateObject(itemType); }
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; }
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; }
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; }
public ItemType VCreateObject(ItemType itemType, IItemTypeService _itemTypeService) { VName(itemType, _itemTypeService); return itemType; }
public bool ValidUpdateObject(ItemType itemType, IItemTypeService _itemTypeService) { itemType.Errors.Clear(); VUpdateObject(itemType, _itemTypeService); return isValid(itemType); }
public bool ValidDeleteObject(ItemType itemType, IItemService _itemService, IMaintenanceService _maintenanceService) { itemType.Errors.Clear(); VDeleteObject(itemType, _itemService, _maintenanceService); return isValid(itemType); }
public bool ValidCreateObject(ItemType itemType, IItemTypeService _itemTypeService) { VCreateObject(itemType, _itemTypeService); return isValid(itemType); }
public bool isValid(ItemType obj) { bool isValid = !obj.Errors.Any(); return isValid; }
public ItemType UpdateObject(ItemType itemType) { return (itemType = _validator.ValidUpdateObject(itemType, this) ? _repository.UpdateObject(itemType) : itemType); }
public ItemType SoftDeleteObject(ItemType itemType, IItemService _itemService, IMaintenanceService _maintenanceService) { return (itemType = _validator.ValidDeleteObject(itemType, _itemService, _maintenanceService) ? _repository.SoftDeleteObject(itemType) : itemType); }
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); }
public ItemType CreateObject(ItemType itemType) { itemType.Errors = new Dictionary<String, String>(); return (_validator.ValidCreateObject(itemType, this) ? _repository.CreateObject(itemType) : itemType); }