public IHttpActionResult CreateOrderDeliveryAddress([FromBody] DeliveryAddress deliveryAddress) { try { OrderDeliveryAddress orderDeliveryAddress = null; long cartId = 0; ClaimsPrincipal principal = Request.GetRequestContext().Principal as ClaimsPrincipal; long.TryParse(principal.Claims.Where(c => c.Type == "participant_Id").Single().Value, out this.participantId); var validation = deliveryAddress.ValidationAddress(); if (!string.IsNullOrEmpty(validation)) { return(BadRequest(validation)); } var cart = this._cartService.Get(this.participantId); var deliveryAddressResult = this._cartService.Get(this.participantId, cart.Id); if (deliveryAddressResult.Id > 0) { orderDeliveryAddress = deliveryAddress.MappingDomain(); orderDeliveryAddress.Id = deliveryAddressResult.Id; orderDeliveryAddress.ParticipantId = this.participantId; orderDeliveryAddress.CartId = cart.Id; orderDeliveryAddress = this._cartService.Add(orderDeliveryAddress); } else { orderDeliveryAddress = deliveryAddress.MappingDomain(); orderDeliveryAddress.ParticipantId = this.participantId; orderDeliveryAddress.CartId = cart.Id; orderDeliveryAddress = this._cartService.Add(orderDeliveryAddress); } cartId = cart.Id; return(Ok(cartId)); } catch (Exception ex) { return(NotFound()); } }