Example #1
0
        public IResult <TissueImage> Add(Image file, int tissueId)
        {
            var result = BusinessRules <TissueImage> .Checker(ImageCountChecker(tissueId));

            TissueImage tissueImage = new TissueImage()
            {
                ImagePath = _localFileSystem.Path,
                Guid      = new GuidGenerator().Generator(),
                Date      = DateTime.Now,
                TissueId  = tissueId,
                Image     = _databaseFileSytem.FileToBytes(file)
            };

            if (result != null)
            {
                foreach (var error in result)
                {
                    return(new FailResult <TissueImage>(error.Message));
                }
            }

            _localFileSystem.Filing(file, tissueImage.Guid);
            _tissueImageDal.Add(tissueImage);

            return(new SuccessResult <TissueImage>(Messages.success));
        }