Пример #1
0
        public async Task <Photo> Upload(IFormFile photo, PhotoType type)
        {
            var photoResults = await _photoService.UploadOriginalsAsync(new IFormFile[] { photo }, type, UserId);

            if (photoResults.Any())
            {
                var photoResult = photoResults.First();

                if (photoResult.Location != null)
                {
                    photoResult.Location = await _locationService.AddOrUpdateLocationAsync(photoResult.Location);
                }

                return(await _photoService.AddOrUpdatePhotoAsync(photoResult));
            }
            return(null);
        }
Пример #2
0
        public async Task <Data.Shared.Models.Origin> AddOrUpdateOriginAsync(Data.Shared.Models.Origin origin, string userId)
        {
            origin.DateModified = DateTime.UtcNow;
            origin.CreatedBy    = userId;

            if (origin.Location != null && origin.Location.IsNotEmpty())
            {
                origin.Location = await _locationService.AddOrUpdateLocationAsync(origin.Location);
            }

            if (origin.ParentOrigin != null && origin.ParentOrigin.OriginId == 0)
            {
                var parentOrigin = await _originRepository.AddOrUpdateAsync(l => l.Id == origin.ParentOrigin.OriginId, origin.ParentOrigin.AsStore());

                origin.ParentOrigin = parentOrigin.AsModel();
            }

            var originResult = await _originRepository.AddOrUpdateAsync(l => l.Id == origin.OriginId, origin.AsStore());

            return(originResult.AsModel());
        }