Beispiel #1
0
        private CustomerIndexModel GetTestSessions()
        {
            var           customers = new List <CustomerModel>();
            CustomerModel c1        = new CustomerModel
            {
                Id          = 1,
                FirstName   = "Alex",
                LastName    = "Morgan",
                PhoneNumber = "+380506767676",
                Email       = "*****@*****.**"
            };

            CustomerModel c2 = new CustomerModel
            {
                Id          = 2,
                FirstName   = "Wess",
                LastName    = "Smith",
                PhoneNumber = "+380506767677",
                Email       = "*****@*****.**"
            };

            customers.Add(c1);
            customers.Add(c2);

            var res = new CustomerIndexModel
            {
                Customer      = customers,
                PageViewModel = new PageModel(2, 1, 2)
            };

            return(res);
        }
Beispiel #2
0
        public CustomerIndexModel Get()
        {
            try
            {
                IEnumerable <CustomerEntity> customers = _salonManager.GetList();

                List <CustomerModel> customersVM = new List <CustomerModel>();
                foreach (CustomerEntity c in customers)
                {
                    customersVM.Add(new CustomerModel
                    {
                        Id          = c.Id,
                        FirstName   = c.FirstName,
                        LastName    = c.LastName,
                        PhoneNumber = c.PhoneNumber,
                        Email       = c.Email
                    });
                }

                CustomerIndexModel viewModel = new CustomerIndexModel
                {
                    Customer = customersVM.OrderBy(x => x.FirstName)
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public void GetCustomersShouldReturnList()
        {
            //Arrange
            List <CustomerModel> list = new List <CustomerModel>();

            list.Add(new CustomerModel {
                Id = 1, Email = "*****@*****.**", FirstName = "Roma", LastName = "Boma", PhoneNumber = "0634518465"
            });
            CustomerIndexModel ivm = new CustomerIndexModel
            {
                Customer = list
            };
            string jsonString = JsonSerializer.Serialize(ivm);

            List <CustomerEntity> temp = new List <CustomerEntity>();

            temp.Add(new CustomerEntity {
                Id = 1, Email = "*****@*****.**", FirstName = "Roma", LastName = "Boma", PhoneNumber = "0634518465"
            });

            var mockCustomer = new Mock <ISalonRepository <CustomerEntity> >();
            var mockOrder    = new Mock <ISalonRepository <OrderEntity> >();
            var getCustomers = new CustomerManager(mockCustomer.Object, mockOrder.Object);

            mockCustomer.Setup(x => x.GetList()).Returns(temp);

            //Act
            var    result      = getCustomers.Get();
            string jsonString2 = JsonSerializer.Serialize(result);

            //Assert
            Assert.AreEqual(jsonString, jsonString2);
        }
        public ActionResult Index()
        {
            CustomerIndexModel model = new CustomerIndexModel();

            model.Customers = CustomerService.All().OrderBy(x => x.Name);

            return(View(model));
        }
Beispiel #5
0
        public async Task <IActionResult> Index()
        {
            /** Direct Implementation
             * List<CustomerIndexListingModel> cmList =  CustomerIndexListingModel
             *  .ConvertQueryMasterToListModel(await queryContext.GetUnResolvedQueryOfCustomerAsync(1));
             * List<CustomerIndexListingModel> resolvedList = CustomerIndexListingModel
             *  .ConvertQueryMasterToListModel(await queryContext.GetRecentResolvedQueryOfCustomerAsync(1));
             *
             * CustomerIndexModel cim = new CustomerIndexModel()
             * {
             *  UnresolvedQuery = cmList,
             *  RecentResolvedQuery = resolvedList
             * };
             *
             * return View(cim);*/

            int custId = 1;
            List <QueryMasterListModel> listModels = new List <QueryMasterListModel>();
            HttpClient          client             = api.Initial();
            HttpResponseMessage res = await client.GetAsync("api/customer/" + custId + "/unresolvedQueries");

            if (res.IsSuccessStatusCode)
            {
                var result = res.Content.ReadAsStringAsync().Result;
                listModels = JsonConvert.DeserializeObject <List <QueryMasterListModel> >(result);
            }

            List <QueryMasterListModel> resolvedlistModels = new List <QueryMasterListModel>();

            client = api.Initial();
            // string uri = Url.Link("GetRecentResolvedQuerys", new { customerId = custId });
            res = await client.GetAsync("api/customer/" + custId + "/recentresolvedQueries");

            // (uri);
            if (res.IsSuccessStatusCode)
            {
                var result = res.Content.ReadAsStringAsync().Result;
                resolvedlistModels = JsonConvert.DeserializeObject <List <QueryMasterListModel> >(result);
            }
            else if (res.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                ViewData["Error"] = "Invalid Customer Id";
            }
            else if (res.StatusCode == HttpStatusCode.NotFound)
            {
                ViewData["Error"] = "Not Found. Or Wrong Parameter.";
            }

            CustomerIndexModel cim = new CustomerIndexModel()
            {
                CustomerUnResolvedQuerys     = listModels,
                CustomerRecentResolvedQuerys = resolvedlistModels
            };

            return(View(cim));
        }
Beispiel #6
0
        public ActionResult Index(string name, string groupId, int page = 1)
        {
            CustomerIndexModel model   = new CustomerIndexModel(name, groupId, page);
            int             totalCount = 0;
            List <Customer> entities   = this.customerService.Search(name, groupId, model.PageIndex, model.PageSize, ref totalCount);

            foreach (Customer entity in entities)
            {
                CustomerPageModel pageModel = new CustomerPageModel(entity);
                pageModel.GroupName = this.GetCustomerGroupName(entity.GroupId);
                model.PageData.Add(pageModel);
            }
            model.TotalCount = totalCount;
            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels   = _assets.getAll();
            var listingResult = assetModels.Select(result => new CustomerIndexListingModel
            {
                Id         = result.CustomerId,
                first_name = _assets.getFirst(result.CustomerId),
                last_name  = _assets.getLast(result.CustomerId)
            });

            var model = new CustomerIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #8
0
        public IActionResult Filter(CustomerIndexModel model, int page = 1)
        {
            var filters = model.Filters;

            if (filters == null)
            {
                return(RedirectToAction("Index", new { page }));
            }

            return(RedirectToAction("Index", new
            {
                page,
                filter = JsonConvert.SerializeObject(filters, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                })
            }));
        }
        public IActionResult Index()
        {
            var customers = _customerservice.GetAll();

            var customerList = customers.Select(
                result => new CustomerViewModel {
                Id            = result.Id,
                Name          = result.Name,
                ContactNumber = result.ContactNumber,
                ImageUrl      = result.ImageUrl,
                City          = result.Address.City
            });

            CustomerIndexModel model = new CustomerIndexModel();

            model.Customers = customerList.ToList();

            return(View(model));
        }
        public IActionResult Index()
        {
            var allCustomers = _customer.GetAll();

            var customerModels = allCustomers.Select(c => new CustomerDetailModel
            {
                Id              = c.Id,
                FirstName       = c.FirstName,
                LastName        = c.LastName,
                StoreCardId     = c.CustomerCard.Id,
                Overdue         = c.CustomerCard.Fees,
                HomeStoreBranch = c.HomeStoreBranch.Name
            }).ToList();

            var model = new CustomerIndexModel()
            {
                Customers = customerModels
            };

            return(View(model));
        }
Beispiel #11
0
        public CustomerIndexModel Get(int page = 1)
        {
            try
            {
                IEnumerable <CustomerEntity> customers = _salonManager.GetList();

                var count = customers.Count();

                int pageSize = 8;

                var items = customers.Skip((page - 1) * pageSize).Take(pageSize).ToList();

                List <CustomerModel> customersVM = new List <CustomerModel>();
                foreach (CustomerEntity c in items)
                {
                    customersVM.Add(new CustomerModel
                    {
                        Id          = c.Id,
                        FirstName   = c.FirstName,
                        LastName    = c.LastName,
                        PhoneNumber = c.PhoneNumber,
                        Email       = c.Email
                    });
                }

                PageModel          pageViewModel = new PageModel(count, page, pageSize);
                CustomerIndexModel viewModel     = new CustomerIndexModel
                {
                    PageViewModel = pageViewModel,
                    Customer      = customersVM
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public ActionResult GetListCustomer(CustomerIndexModel model)
 {
     PopulateIndexModel(model);
     return JsonObject(true, string.Empty, new
     {
         html = PartialViewToString("BaseView/Customer/_list", model)
     });
 }
 public ActionResult GetDropDownDistrictsForFilterIndex(CustomerIndexModel model)
 {
     return JsonObject(true, string.Empty, new
     {
         dropDownDistrict = PartialViewToString("BaseView/Customer/_dropDownDistrict", model)
     });
 }
        public ActionResult ExportCustomers(CustomerIndexModel model)
        {
            model.IsExport = true;
            PopulateIndexModel(model);

            var name = CustomerType == CustomerType.Current
                ? CustomerType + " " + "Customers"
                : CustomerType.ToString();

            var ef = new ExcelFile();

            var ws = ef.Worksheets.Add(name);

            var ri = 0;
            var ci = 0;

            Action<ExcelCell> fontmatCaption = cell =>
            {
                cell.Style.Font.Weight = ExcelFont.BoldWeight;
                cell.Style.VerticalAlignment = VerticalAlignmentStyle.Top;
            };

            #region header

            ws.Cells[ri, ci].Value = "ClinicId";
            fontmatCaption(ws.Cells[ri, ci]);

            ++ci;
            ws.Cells[ri, ci].Value = "ClinicName";
            fontmatCaption(ws.Cells[ri, ci]);

            ++ci;
            ws.Cells[ri, ci].Value = "ClinicEmail";
            fontmatCaption(ws.Cells[ri, ci]);

            ++ci;
            ws.Cells[ri, ci].Value = "ClinicPhone";
            fontmatCaption(ws.Cells[ri, ci]);

            ++ci;
            ws.Cells[ri, ci].Value = "DentistName";
            fontmatCaption(ws.Cells[ri, ci]);

            ++ci;
            ws.Cells[ri, ci].Value = "DentistEmail";
            fontmatCaption(ws.Cells[ri, ci]);

            ++ci;
            ws.Cells[ri, ci].Value = "DentistPhone";
            fontmatCaption(ws.Cells[ri, ci]);

            #endregion

            #region body

            foreach (var item in model.Results)
            {
                ++ri;
                ci = 0;

                ws.Cells[ri, ci++].Value = item.ClinicId;
                ws.Cells[ri, ci++].Value = item.ClinicName;
                ws.Cells[ri, ci++].Value = item.ClinicEmail;
                ws.Cells[ri, ci++].Value = item.ClinicPhone;
                ws.Cells[ri, ci++].Value = item.DentistName;
                ws.Cells[ri, ci++].Value = item.DentistEmail;
                ws.Cells[ri, ci++].Value = item.DentistPhone;
            }

            #endregion

            var cd = new System.Net.Mime.ContentDisposition
            {
                FileName = name + ".xls",

                // always prompt the user for downloading, set to true if you want
                // the browser to try to show the file inline
                Inline = false,
            };

            Response.AppendHeader("Content-Disposition", cd.ToString());

            var memoryStream = new MemoryStream();

            ef.SaveXls(memoryStream);

            memoryStream.Position = 0;

            return File(memoryStream, "application/ms-excel");
        }
        protected void PopulateIndexModel(CustomerIndexModel model)
        {
            model.CustomerType = CustomerType;

            model.InitSortInfo();

            if (string.IsNullOrWhiteSpace(model.SortBy))
            {
                model.SortBy = "ClinicId";
            }

            var filter = new FindRequest
            {
                CustomerType = model.CustomerType,
                ClinicId = model.ClinicId,
                ClinicName = model.ClinicName,
                DentistName = model.DentistName,
                ClinicPhone = model.ClinicPhone,
                Address = model.Address,
                Email = model.Email,
                City = model.City,
                District = model.District,
                InterestingDevice = model.InterestingDevice,
                UsingRC = model.UsingRC,
                AssignTo = model.AssignTo,
                VisitFrom = model.VisitFrom.ToStartDateTimeNull(),
                VisitTo = model.VisitTo.ToEndDateTimeNull(),
                SortOption = new SortOption(new[] { new SortItem(model.SortBy, model.SortDirection.Value) })
            };

            if (!model.IsExport)
            {
                filter.PageOption = new PageOption
                {
                    PageSize = model.Pagination.PageSize,
                    PageNumber = model.Pagination.CurrentPageIndex
                };
            }

            var response = ServiceHelper.Customer.ExecuteDispose(s => s.FindCustomers(filter));
            model.Results = response.Results.MapList<CustomerModel>();
            model.Pagination.TotalRecords = response.TotalRecords;
        }
Beispiel #16
0
        public IActionResult Index(string filter, int page = 1)
        {
            var filtedObj = new CustomerIndexFilterModel();

            if (!string.IsNullOrEmpty(filter))
            {
                filtedObj = JsonConvert.DeserializeObject <CustomerIndexFilterModel>(filter);
            }

            if (User.IsInRole(RoleNames.Employee))
            {
                filtedObj.CityId = CurrentUser?.City?.Id;
            }

            var typesHousings = _context.TypesHousing.ToList();

            var filterData = new CustomersExtension.FilterParams
            {
                CityId    = filtedObj.CityId,
                PriceTo   = filtedObj.MinCost,
                PriceFrom = filtedObj.MaxCost,
                Page      = page,
                //IsArchived = filtedObj.IsArchive,
                IsSiteAccessOnly = filtedObj.IsSiteAccessOnly
            };

            if (filtedObj.DistrictId.HasValue)
            {
                filterData.DistrictIds = new int[] { filtedObj.DistrictId.Value };
            }

            if (filtedObj.HousingTypeId.HasValue)
            {
                filterData.HouseTypeIds = new int[] { filtedObj.HousingTypeId.Value };
            }

            var applicationDbContext = _context.Clients
                                       .Include(c => c.City)
                                       .Include(c => c.CustomerAccount)
                                       .Include(c => c.Smses)
                                       .Include(c => c.User)
                                       .Include(c => c.TypesHousingToCustomers)
                                       .Include(x => x.DistrictToClients)
                                       .Include(x => x.Phones);

            var query = applicationDbContext.Where(x => CustomersExtension.Filter(filterData)(x));

            int totalPages;
            int totalRows;
            var dbItems = query.PagedResult(page, 20, x => x.User, false, out totalRows, out totalPages).ToList();

            ViewBag.TotalItems         = _context.Clients.Count();
            ViewBag.FilteredItemsCount = totalRows;

            var model = new CustomerIndexModel
            {
                Items       = dbItems.Select(x => CustomerEditModel.Create(x)).ToList(),
                Filters     = filtedObj,
                TotalPages  = totalPages,
                CurrentPage = page
            };

            return(View(model));
        }
 public ActionResult Index(CustomerIndexModel model)
 {
     PopulateIndexModel(model);
     return View(model);
 }