/// <summary> /// Validating typeOfAccountUnit /// </summary> /// <param name="typeOfAccountUnit"></param> /// <returns></returns> protected virtual async Task ValidateTypeOfAccountUnitAsync(TypeOfAccountUnit typeOfAccountUnit) { if (!typeOfAccountUnit.IsEditable) { throw new UserFriendlyException(L("Predefined Classification is not editable", typeOfAccountUnit.Description)); } if (TypeOfAccountUnitRepository != null) { var typeOfaccount = (await TypeOfAccountUnitRepository.GetAllListAsync(p => p.Description == typeOfAccountUnit.Description)); if (typeOfAccountUnit.Id == 0) { if (typeOfaccount.Count > 0) { throw new UserFriendlyException(L("Duplicate Classification", typeOfAccountUnit.Description)); } } else { if (typeOfaccount.FirstOrDefault(p => p.Id != typeOfAccountUnit.Id && p.Description == typeOfAccountUnit.Description) != null) { throw new UserFriendlyException(L("Duplicate Classification", typeOfAccountUnit.Description)); } } } }
/// <summary> /// Get the Classification based on TypeOfAccountId. /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <TypeOfAccountUnitDto> GetClassificationUnitById(IdInput input) { TypeOfAccountUnit typeOfAccountUnit = await _typeOfAccountUnitRepository.GetAsync(input.Id); TypeOfAccountUnitDto result = typeOfAccountUnit.MapTo <TypeOfAccountUnitDto>(); result.TypeOfAccountId = typeOfAccountUnit.Id; return(result); }
/// <summary> /// Updating typeOfAccountUnit Details /// </summary> /// <param name="typeOfAccountUnit"></param> /// <returns></returns> public virtual async Task UpdateAsync(TypeOfAccountUnit typeOfAccountUnit) { await ValidateTypeOfAccountUnitAsync(typeOfAccountUnit); await TypeOfAccountUnitRepository.UpdateAsync(typeOfAccountUnit); }
public virtual async Task <int> CreateAsync(TypeOfAccountUnit typeOfAccountUnit) { await ValidateTypeOfAccountUnitAsync(typeOfAccountUnit); return(await TypeOfAccountUnitRepository.InsertAndGetIdAsync(typeOfAccountUnit)); }