private Image Create(int serviceSupplierId, Models.Requests.RoomImage image) => new Image { ReferenceId = image.RoomId, ImageType = ImageTypes.RoomImage, OriginalImageDetails = new OriginalImageDetails { OriginalName = image.UploadedFile.FileName, OriginalContentType = image.UploadedFile.ContentType }, ServiceSupplierId = serviceSupplierId, Created = _dateTimeProvider.UtcNow(), Description = JsonDocumentUtilities.CreateJDocument(new MultiLanguage <string> { Ar = string.Empty, En = string.Empty, Ru = string.Empty }) };
public Task <Result <Guid> > Add(Models.Requests.RoomImage image) { return(_managerContext.GetServiceSupplier() .Check(serviceSupplier => _serviceSupplierContext.EnsureRoomBelongsToServiceSupplier(serviceSupplier, image.AccommodationId, image.RoomId)) .Bind(serviceSupplier => Validate(image, serviceSupplier)) .Tap(manager => ResortImages(manager.Id, image.RoomId, ImageTypes.RoomImage)) .Map(manager => Create(manager.Id, image)) .Ensure(dbImage => ValidateImageType(image.UploadedFile).Value, "Invalid image file type") .Bind(dbImage => ConvertAndUpload(dbImage, image.UploadedFile)) .Bind(AddSlimImageToRoom)); Result <ServiceSupplier> Validate(Models.Requests.RoomImage image, ServiceSupplier serviceSupplier) { var validationResult = ValidationHelper.Validate(image, new RoomImageValidator()); return(validationResult.IsFailure ? Result.Failure <ServiceSupplier>(validationResult.Error) : Result.Success(serviceSupplier)); } }
public async Task <Result <Guid> > Add(Models.Requests.RoomImage image) { throw new NotImplementedException(); }