public string Put(Guid id, [FromBody] QuoteRequest request) { if (request == null || !request.IsValid()) { return("Invalid Request"); } try { Quote quote = new Quote(id); quote.Name = request.Name; quote.Surname = request.Surname; quote.Email = request.Email; quote.ContactNumber = request.ContactNumber; foreach (var item in request.Items) { var orderItem = new OrderItem(); orderItem.productGuid = item.productGuid; orderItem.Quantity = item.Quantity; quote.Items.Add(orderItem); } Repository.AddOrUpdate(quote); return("Success"); } catch (Exception ex) { throw ex; } }
public void IsValid_WhereInvalidRequestSupplied_ReturnsFalse() { var validRequest = new QuoteRequest { Email = "" }; Assert.IsFalse(validRequest.IsValid()); }
public void IsValid_WhereValidRequestSupplied_ReturnsTrue() { var validRequest = new QuoteRequest { Name = "Quote", Surname = "Request", Email = "*****@*****.**", ContactNumber = "111111" }; Assert.IsTrue(validRequest.IsValid()); }