public CustomerReviewEntity FromModel(CustomerReview customerReview, PrimaryKeyResolvingMap pkMap)
        {
            if (customerReview == null)
            {
                throw new ArgumentNullException(nameof(customerReview));
            }

            pkMap.AddPair(customerReview, this);

            Id           = customerReview.Id;
            CreatedBy    = customerReview.CreatedBy;
            CreatedDate  = customerReview.CreatedDate;
            ModifiedBy   = customerReview.ModifiedBy;
            ModifiedDate = customerReview.ModifiedDate;

            AuthorNickname = customerReview.AuthorNickname;
            Content        = customerReview.Content;
            IsActive       = customerReview.IsActive;
            ProductId      = customerReview.ProductId;
            ProductRating  = customerReview.ProductRating;
            var propertyValues = customerReview.PropertyValues
                                 .Select(x => AbstractTypeFactory <FavoritePropertyValueEntity>
                                         .TryCreateInstance()
                                         .FromModel(x, pkMap));

            PropertyValues = new ObservableCollection <FavoritePropertyValueEntity>(propertyValues);

            return(this);
        }
        public OtherInformationPage(CustomerReview customer, CustomerImages images)
        {
            InitializeComponent();
            this.customer = customer;
            licenceIssueDate.MaximumDate  = DateTime.Now;
            licenceExpiryDate.MinimumDate = DateTime.Now;
            _token = App.Current.Properties["currentToken"].ToString();
            GetAllStateForMobileRequest stateRequest = new GetAllStateForMobileRequest();
            List <string> stateList = new List <string>();

            stateRequest.CountryID = (int)customer.CountryId;
            stateResponse          = getStates(stateRequest, _token);
            if (stateResponse.stateList.Count > 0)
            {
                foreach (State s in stateResponse.stateList)
                {
                    stateList.Add(s.StateCode);
                }
                ;
            }
            licenceStatePicker.ItemsSource = stateList;
            imageMobileRequest             = new UploadCustomerImageMobileRequest();
            imageMobileResponse            = null;
            this.images           = images;
            licExpireDateSelected = false;
            licIssueDateSelected  = false;
            licfrontIamgeStat     = new CustomerImages();
            licBackIamgeStat      = new CustomerImages();
            LicenceImagesRequest  = new AddLicenceImagesRequest();
            licenceImageResponse  = null;
        }
        public CustomerReview getCustomerById(int customerId, string token)
        {
            CustomerReview customerReview = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "Customer/GetCustomer");
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    var url = string.Format(
                        client.BaseAddress +
                        "?customerId=" +
                        customerId);

                    var response = client.GetAsync(url).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var responseStream = response.Content.ReadAsStringAsync().Result;
                        customerReview = JsonConvert.DeserializeObject <CustomerReview>(responseStream);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(customerReview);
        }
Ejemplo n.º 4
0
 public Review(CustomerReview customerReview)
 {
     this.Comment      = customerReview.Comment;
     this.DateOfReview = customerReview.CreatedDate;
     this.Location     = customerReview.Location;
     this.Rating       = customerReview.Rating;
 }
Ejemplo n.º 5
0
        public CustomerReview SubmitCustomerReview(CustomerReview review)
        {
            return(AttemptRequest(review.IpAddress, () =>
            {
                if (_context.CustomerReviews.Any(p => p.IpAddress == review.IpAddress &&
                                                 p.Rating == review.Rating &&
                                                 p.Comment == review.Comment))
                {
                    throw new Exception("You have already entered this comment. Thank you!");
                }

                if (_context.CustomerReviews
                    .Count(p => p.IpAddress == review.IpAddress &&
                           p.CreatedDate.Year == DateTime.Now.Year &&
                           p.CreatedDate.Month == DateTime.Now.Month)
                    > MaxMonthlyCommentThreshhold)
                {
                    throw new Exception($"You have reviewed us too often. You can enter {MaxMonthlyCommentThreshhold} comments per IP address.  We appreciate your support.");
                }

                _context.CustomerReviews.Add(review);
                _context.SaveChanges();
                return _context.CustomerReviews
                .Include("Location")
                .First(p => p.Id == review.Id);
            }));
        }
Ejemplo n.º 6
0
        public IHttpActionResult PutCustomerReview(int id, CustomerReview customerReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customerReview.Id)
            {
                return(BadRequest());
            }

            db.Entry(customerReview).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerReviewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 7
0
        public void CanRecountAverageProductRate()
        {
            // Create review for test
            var item = new CustomerReview
            {
                Id             = CustomerReviewId,
                ProductId      = ProductId,
                CreatedDate    = DateTime.Now,
                CreatedBy      = "initial data seed",
                AuthorNickname = "John Doe",
                Content        = "Liked that",
                Rate           = 5
            };

            CustomerReviewService.SaveCustomerReviews(new[] { item });

            // Check result
            var getByIdsResult = AverageProductRateService.GetByProductIds(new[] { ProductId });

            Assert.Single(getByIdsResult);

            var avgRate = getByIdsResult[0];

            Assert.Equal(ProductId, avgRate.ProductId);
            Assert.Equal(item.Rate, avgRate.AverageRate);

            // Delete test review
            CanDeleteCustomerReviews();
        }
Ejemplo n.º 8
0
 private void AddProductId(HashSet <string> ids, CustomerReview review)
 {
     if (review != null && !ids.Contains(review.ProductId))
     {
         ids.Add(review.ProductId);
     }
 }
Ejemplo n.º 9
0
        private CustomerReview[] GetReviews(HtmlDocument htmlDoc)
        {
            var nodes = htmlDoc.DocumentNode
                        .SelectNodes(CustomerReviewPage_ArticleNodes).ToArray();

            if (nodes == null || nodes.Length == 0)
            {
                return(null);
            }

            var items = new CustomerReview[nodes.Length];

            for (int i = 0; i < items.Length; i++)
            {
                try
                {
                    var item = new CustomerReview();

                    item.Title   = nodes[i].SelectSingleNode(@"./*//a[@data-hook='review-title']/span").InnerText.Trim();
                    item.RawDate = nodes[i].SelectSingleNode(@"./*//span[@data-hook='review-date']").InnerText.Trim();
                    item.Rating  = nodes[i].SelectSingleNode(@"./*//i[@data-hook='review-star-rating']/span").InnerText.Trim();
                    item.Content = nodes[i].SelectSingleNode(@"./*//span[@data-hook='review-body']/span").InnerText.Trim();
                    items[i]     = item;
                }
                catch (Exception) { }
            }

            return(items);
        }
Ejemplo n.º 10
0
        public int registerUser(CustomerReview customer, string _token)
        {
            int customerId = 0;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "Registration/RegisterCustomer");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token);

                    var myContent   = JsonConvert.SerializeObject(customer);
                    var buffer      = Encoding.UTF8.GetBytes(myContent);
                    var byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                    var response = client.PostAsync(client.BaseAddress, byteContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var responseStream = response.Content.ReadAsStringAsync().Result;
                        customerId = JsonConvert.DeserializeObject <int>(responseStream);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(customerId);
        }
        public virtual CustomerReview ToModel(CustomerReview customerReview)
        {
            if (customerReview == null)
            {
                throw new ArgumentNullException(nameof(customerReview));
            }

            customerReview.Id           = Id;
            customerReview.CreatedBy    = CreatedBy;
            customerReview.CreatedDate  = CreatedDate;
            customerReview.ModifiedBy   = ModifiedBy;
            customerReview.ModifiedDate = ModifiedDate;

            customerReview.AuthorNickname = AuthorNickname;
            customerReview.Content        = Content;
            customerReview.IsActive       = IsActive;
            customerReview.ProductId      = ProductId;

            customerReview.Pros         = Pros;
            customerReview.Cons         = Cons;
            customerReview.Rating       = Rating;
            customerReview.RatingNumber = (int)Rating;
            customerReview.RatingTypes  = Enum.GetNames(typeof(Rating));

            return(customerReview);
        }
        public virtual CustomerReviewEntity FromModel(CustomerReview customerReview, PrimaryKeyResolvingMap pkMap)
        {
            if (customerReview == null)
            {
                throw new ArgumentNullException(nameof(customerReview));
            }

            pkMap.AddPair(customerReview, this);

            Id           = customerReview.Id;
            CreatedBy    = customerReview.CreatedBy;
            CreatedDate  = customerReview.CreatedDate;
            ModifiedBy   = customerReview.ModifiedBy;
            ModifiedDate = customerReview.ModifiedDate;

            AuthorNickname = customerReview.AuthorNickname;
            Content        = customerReview.Content;
            IsActive       = customerReview.IsActive;
            ProductId      = customerReview.ProductId;

            Pros   = customerReview.Pros;
            Cons   = customerReview.Cons;
            Rating = customerReview.Rating;

            return(this);
        }
        public AddNewDriver(ReservationView reservationView, CustomerSerach filter)
        {
            InitializeComponent();


            //want to edit
            selectedVehicle = null;



            customer             = new CustomerReview();
            this.filter          = filter;
            customerID           = 0;
            this.reservationView = reservationView;
            _token = App.Current.Properties["currentToken"].ToString();

            DateOfBithEntry.MaximumDate = DateTime.Now.AddYears(-18);
            countryResponse             = getAllCountry(_token);
            List <string> countryList = new List <string>();

            if (countryResponse.countryList.Count > 0)
            {
                foreach (Country k in countryResponse.countryList)
                {
                    countryList.Add(k.CountryName);
                }
                ;
            }
            countryPicker.ItemsSource = countryList;

            countryPicker.SelectedItem = "USA";
            List <string> stateList = new List <string>();
            int?          counid    = null;

            foreach (Country c in countryResponse.countryList)
            {
                if (c.CountryName == countryPicker.SelectedItem.ToString())
                {
                    counid = c.CountryId;
                }
            }
            ;

            if (counid != null)
            {
                GetAllStateForMobileRequest stateRequest = new GetAllStateForMobileRequest();
                stateRequest.CountryID = counid.Value;
                stateResponse          = getStates(stateRequest, _token);
                if (stateResponse.stateList.Count > 0)
                {
                    foreach (State s in stateResponse.stateList)
                    {
                        stateList.Add(s.StateName);
                    }
                    ;
                }
                statePicker.ItemsSource = stateList;
            }
        }
Ejemplo n.º 14
0
        public async Task <bool> CreateReviewAsync(CustomerReview customerReview)
        {
            await _dbContext.AddAsync(customerReview);

            await _dbContext.SaveChangesAsync();

            return(true);
        }
        public void CanDoCRUDandSearch()
        {
            // Read non-existing item
            var getByIdsResult = CustomerReviewService.GetByIds(new[] { CustomerReviewId });

            Assert.NotNull(getByIdsResult);
            Assert.Empty(getByIdsResult);

            // Create
            var item = new CustomerReview
            {
                Id             = CustomerReviewId,
                ProductId      = ProductId,
                CreatedDate    = DateTime.Now,
                CreatedBy      = "initial data seed",
                AuthorNickname = "John Doe",
                Content        = "Liked that",
                Virtues        = "Liked that!",
                Disadvantages  = "Not",
                Rate           = 3
            };

            CustomerReviewService.SaveCustomerReviews(new[] { item });

            getByIdsResult = CustomerReviewService.GetByIds(new[] { CustomerReviewId });
            Assert.Single(getByIdsResult);

            item = getByIdsResult[0];
            Assert.Equal(CustomerReviewId, item.Id);

            // Update
            var updatedContent = "Updated content";

            Assert.NotEqual(updatedContent, item.Content);

            item.Content = updatedContent;
            CustomerReviewService.SaveCustomerReviews(new[] { item });
            getByIdsResult = CustomerReviewService.GetByIds(new[] { CustomerReviewId });
            Assert.Single(getByIdsResult);

            item = getByIdsResult[0];
            Assert.Equal(updatedContent, item.Content);

            // Search
            Assert.Throws <ArgumentNullException>(() => CustomerReviewSearchService.SearchCustomerReviews(null));

            var criteria = new CustomerReviewSearchCriteria {
                ProductIds = new[] { ProductId }
            };
            var searchResult = CustomerReviewSearchService.SearchCustomerReviews(criteria);

            Assert.NotNull(searchResult);
            Assert.Equal(1, searchResult.TotalCount);
            Assert.Single(searchResult.Results);

            // Delete
            CanDeleteCustomerReviews();
        }
Ejemplo n.º 16
0
        public async Task <CustomerReview> AddCustomerReview(CustomerReview customerReview)
        {
            var model = customerReview.ToApiModel();

            await _customerReviewsApi.UpdateWithHttpMessagesAsync(new List <Api.CustomerReview> {
                model
            });

            return(customerReview);
        }
Ejemplo n.º 17
0
        public void CanDoReviewCRUDandSearch()
        {
            //Read non-existing item
            var getByIdsResult = _customerReviewService.GetReviewByIds(new[] { _customerReviewId });

            Assert.NotNull(getByIdsResult);
            Assert.Empty(getByIdsResult);

            //Create new item
            var item = new CustomerReview
            {
                Id             = _customerReviewId,
                ProductId      = _productId,
                CreatedDate    = DateTime.Now,
                CreatedBy      = "initial data seed",
                AuthorNickname = "John Doe",
                Content        = "Liked that"
            };

            _customerReviewService.SaveCustomerReviews(new[] { item });

            getByIdsResult = _customerReviewService.GetReviewByIds(new[] { _customerReviewId });
            Assert.Single(getByIdsResult);

            item = getByIdsResult[0];
            Assert.Equal(_customerReviewId, item.Id);

            //Update existing item
            var updatedConent = "Updated content";

            Assert.NotEqual(updatedConent, item.Content);

            item.Content = updatedConent;
            _customerReviewService.SaveCustomerReviews(new[] { item });
            getByIdsResult = _customerReviewService.GetReviewByIds(new[] { _customerReviewId });
            Assert.Single(getByIdsResult);

            item = getByIdsResult[0];
            Assert.Equal(updatedConent, item.Content);

            //Search by creteria
            Assert.Throws <ArgumentNullException>(() => _customerReviewSearchService.SearchCustomerReviews(null));

            var criteria = new CustomerReviewSearchCriteria {
                ProductIds = new[] { _productId }, AuthorId = _authorId
            };
            var searchResult = _customerReviewSearchService.SearchCustomerReviews(criteria);

            Assert.NotNull(searchResult);
            Assert.Equal(1, searchResult.TotalCount);
            Assert.Single(searchResult.Results);

            //Delete existing item
            CanDeleteCustomerReviews();
        }
Ejemplo n.º 18
0
        public RegisterPage()
        {
            InitializeComponent();

            customer             = new CustomerReview();
            customerSerach       = new CustomerSerach();
            customerSeachResults = null;
            //var assembly = typeof(LoginPage);
            //regiseterNxtBtn.ImageSource = ImageSource.FromResource("BespokeMobile.Assets.nextIcon.png", assembly);
            //registerPageImage.Source= ImageSource.FromResource("BespokeMobile.Assets.registerPageImage.png", assembly);
        }
Ejemplo n.º 19
0
        public IHttpActionResult GetCustomerReview(int id)
        {
            CustomerReview customerReview = db.CustomerReviews.Find(id);

            if (customerReview == null)
            {
                return(NotFound());
            }

            return(Ok(customerReview));
        }
        public void ToModel_ShouldThrowArgumentNullException_IfInputModelIsNull()
        {
            //arrange
            var            entity     = randomizer.Create <CustomerReviewEntity>();
            CustomerReview inputModel = null;

            //act
            Action act = () => entity.ToModel(inputModel);

            //assert
            act.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 21
0
        public ActionResult AjaxForm()
        {
            var model = new CustomerReview();

            if (DoAction == ActionType.Edit)
            {
                model = _da.GetById(ArrId.FirstOrDefault());
            }
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View(model));
        }
Ejemplo n.º 22
0
        public RegisterPage(int fromVal)
        {
            InitializeComponent();

            customer             = new CustomerReview();
            customerSerach       = new CustomerSerach();
            customerSeachResults = null;
            //var assembly = typeof(LoginPage);
            //regiseterNxtBtn.ImageSource = ImageSource.FromResource("MaxVonGrafKftMobile.Assets.nextIcon.png", assembly);
            //registerPageImage.Source= ImageSource.FromResource("MaxVonGrafKftMobile.Assets.registerPageImage.png", assembly);
            this.fromVal = fromVal;
        }
Ejemplo n.º 23
0
        public IHttpActionResult PostCustomerReview(CustomerReview customerReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CustomerReviews.Add(customerReview);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = customerReview.Id }, customerReview));
        }
        public void FromModel_ShouldThrowArgumentNullException_IfInputModelIsNull()
        {
            //arrange
            var            entity     = randomizer.Create <CustomerReviewEntity>();
            CustomerReview inputModel = null;
            var            map        = randomizer.Create <PrimaryKeyResolvingMap>();

            //act
            Action act = () => entity.FromModel(inputModel, map);

            //assert
            act.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 25
0
        public static CustomerReview ToShopifyModel(this storefrontModel.CustomerReview customerReview)
        {
            var result = new CustomerReview
            {
                ProductId      = customerReview.ProductId,
                AuthorNickname = customerReview.AuthorNickname,
                Content        = customerReview.Content,
                CreatedDate    = customerReview.CreatedDate,
                IsActive       = customerReview.IsActive,
                Rating         = customerReview.Rating,
            };

            return(result);
        }
Ejemplo n.º 26
0
        public async Task <bool> UpdateReviewAsync(CustomerReview customerReview)
        {
            try
            {
                _dbContext.CustomerReview.Update(customerReview);
                await _dbContext.SaveChangesAsync();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 27
0
        public IHttpActionResult DeleteCustomerReview(int id)
        {
            CustomerReview customerReview = db.CustomerReviews.Find(id);

            if (customerReview == null)
            {
                return(NotFound());
            }

            db.CustomerReviews.Remove(customerReview);
            db.SaveChanges();

            return(Ok(customerReview));
        }
        public CustomerReview getCustomerById(int customerId, string token)
        {
            CustomerReview customerReview = new CustomerReview();

            try
            {
                customerReview = customerService.getCustomerById(customerId, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(customerReview);
        }
Ejemplo n.º 29
0
        public UpdateProfile(CustomerReview customerReview)
        {
            InitializeComponent();
            DateOfBithEntry.MaximumDate = DateTime.Now.AddYears(-18);
            //licIssueDate.MaximumDate = DateTime.Now;
            licenceexpiDate.MinimumDate = DateTime.Now;
            this.customerReview         = customerReview;
            _token                                = App.Current.Properties["currentToken"].ToString();
            customerId                            = (int)Application.Current.Properties["CustomerId"];
            countryResponse                       = null;
            stateResponse                         = null;
            ProfileDetailsMobileRequest           = new UpdateCustomerProfileDetailsMobileRequest();
            profileDetailsMobileResponse          = null;
            portalDetailsMobileRequest            = new GetCustomerPortalDetailsMobileRequest();
            portalDetailsMobileRequest.customerId = customerId;
            PortalDetailsMobileResponse           = null;
            customoerController                   = new CustomerController();
            Images                                = null;
            //licenceIssueDate.MaximumDate = DateTime.Now;
            //licenceExpiryDate.MinimumDate = DateTime.Now;
            licExpireDateSelected = false;
            licIssueDateSelected  = false;
            licfrontIamgeStat     = new CustomerImages();
            licBackIamgeStat      = new CustomerImages();
            LicenceImagesRequest  = new AddLicenceImagesRequest();
            licenceImageResponse  = null;

            var editPhoto = new TapGestureRecognizer();

            editPhoto.Tapped += (s, e) =>
            {
                if (Images != null)
                {
                    if (Images.Base64 == null)
                    {
                        PopupNavigation.PushAsync(new editPrrofilePhotoPage());
                    }
                    else
                    {
                        PopupNavigation.PushAsync(new editPrrofilePhotoPage(Images));
                    }
                }
                else
                {
                    PopupNavigation.PushAsync(new editPrrofilePhotoPage());
                }
            };
            profileImage.GestureRecognizers.Add(editPhoto);
        }
Ejemplo n.º 30
0
        public virtual ExportableCustomerReview FromModel(CustomerReview source)
        {
            Type           = nameof(CustomerReview);
            Id             = source.Id;
            AuthorNickname = source.AuthorNickname;
            Content        = source.Content;
            IsActive       = source.IsActive;
            ProductId      = source.ProductId;
            CreatedBy      = source.CreatedBy;
            CreatedDate    = source.CreatedDate;
            ModifiedBy     = source.ModifiedBy;
            ModifiedDate   = source.ModifiedDate;

            return(this);
        }