/// <summary> /// Converts the product user model to entity. /// </summary> /// <param name="productUserModel">The product user model.</param> /// <returns></returns> private static ProductUserEntity ConvertProductUserModelToEntity(ProductUserModel productUserModel) { return(new ProductUserEntity { ProductUserId = productUserModel.ProductUserId, FirstName = productUserModel.FirstName, LastName = productUserModel.LastName, MobileNumber = $"{productUserModel.MobileCountryId}{productUserModel.MobileNumber}", EmailAddress = productUserModel.EmailAddress, Product = new ProductEntity { ProductCode = productUserModel.Product.ProductCode }, }); }
public HttpResponseMessage ManageProductUser(ProductUserModel productUserModel) { try { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } var response = InitializeProductUserLogic.ManageProductUser(ConvertProductUserModelToEntity(productUserModel)); return(Request.CreateResponse(response != null && !response.IsSuccess ? HttpStatusCode.OK : HttpStatusCode.BadRequest, ConvertProductUserEntityToProductUserModel(response))); } catch (Exception exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, exception)); } }