예제 #1
0
        public async Task <Guid> AddSupply(SuppliesDto supply)
        {
            try
            {
                var validator        = new SuppliesValidator(_unitOfWork.Suppliess);
                var validationResult = await validator.ValidateAsync(supply);

                if (validationResult.Errors.Count > 0)
                {
                    throw new ValidationException(validationResult);
                }
                var suppli = _mapper.Map <Supplement>(supply);
                suppli.Number = await GenerateSupplyNumber();



                suppli = await _unitOfWork.Suppliess.AddAsync(suppli);

                await _unitOfWork.SaveChangesAsync();

                return(suppli.Id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public async Task UpdateSupply(SuppliesDto supplyDto)
        {
            var supply = _mapper.Map <Supplement>(supplyDto);
            await _unitOfWork.Suppliess.UpdateAsync(supply);

            StatusClass = "alert-success";
            Message     = "Supply updated successfully.";
            Saved       = true;
        }