public async Task <CreateOrUpdateProductResult> CreateOrUpdateProductAsync(CreateOrUpdateProductCommand command) { try { var result = await RepositoryManager.Instance.CreateOrUpdateProductAsync(new Product { Id = string.IsNullOrEmpty(command.Id) ? Guid.NewGuid().ToString() : command.Id, Name = command.Name, Description = command.Description, ImageUrl = command.ImageUrl, RedirectUrl = command.RedirectUrl, RowKey = Guid.NewGuid().ToString(), PartitionKey = Guid.NewGuid().ToString() }); return(new CreateOrUpdateProductResult { IsSuccess = result == null ? false : true, ResponseStatusCode = result == null ? System.Net.HttpStatusCode.BadRequest : System.Net.HttpStatusCode.OK, Product = result == null ? null : new ProductViewModel { Id = result.Id, Name = result.Name, Description = result.Description, ImageUrl = result.ImageUrl, RedirectUrl = result.RedirectUrl } }); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <CreateOrUpdateProductResult> CreateOrUpdate([FromBody] CreateOrUpdateProductCommand command) { var result = await productsRepository.CreateOrUpdateProductAsync(command); return(result); }