Example #1
0
        public async Task <Guid> AddComplaintAsync(ComplaintCreationModel complaint)
        {
            ArgumentGuard.NotNull(complaint, nameof(complaint));

            var prodcut = _productService.GetProductAsync(complaint.ProductId);

            if (prodcut.IsNull())
            {
                throw new Exception("Unable to post complain for non-existing product");
            }

            var complaintEntity = Mapper.Map <ComplaintEntity>(complaint);

            complaintEntity.Id             = Guid.NewGuid();
            complaintEntity.CreatedTimeUtc = DateTime.Now;
            complaintEntity.Status         = ComplaintStatus.Created;

            return(await _complaintRepository.AddAsync(complaintEntity));
        }
Example #2
0
 public async Task <Guid> AddComplaintAsync([FromForm] ComplaintCreationModel complaint)
 {
     return(await _complaintService.AddComplaintAsync(complaint));
 }