Ejemplo n.º 1
0
 private void SaveManager_Click(object sender, EventArgs e)
 {
     this.Repository.Save(new Manager()
     {
         Name    = NameText.Text,
         Surname = SurnameText.Text,
         Age     = Convert.ToInt32(AgeText.Text),
         Phone   = PhoneText.Text
     });
     ManagersGrid.DataSource = Repository.GetAll();
 }
        public ICollection <ManagerView> GetAll()
        {
            using var managerRepository = new ManagerRepository();
            var products = managerRepository.GetAll();

            return(_mapper.Map <ICollection <ManagerView> >(products));
        }
Ejemplo n.º 3
0
 private void PopulateGridView()
 {
     this.dgvManager.AutoGenerateColumns = false;
     this.dgvManager.DataSource          = mrepo.GetAll();
     this.dgvManager.Refresh();
     this.dgvManager.ClearSelection();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// search and filter manager
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public async Task <ViewResult <PageModel <ManagerModel> > > Search(int?page, int?pageSize, string filter = null)
        {
            var result = new ViewResult <PageModel <ManagerModel> >();

            try
            {
                var managers = await _managerRepository.GetAll();

                int currentPage     = page.Value;
                int currentPageSize = pageSize.Value;
                List <ManagerModel> managerModels = null;
                int totalManagerModels;
                if (!string.IsNullOrEmpty(filter))
                {
                    filter        = filter.Trim().ToLower();
                    managerModels = managers.Select(x => x.ToManagerModel()).Where(c => c.Name.ToLower().Contains(filter)).OrderBy(c => c.Name)
                                    .Skip(currentPage * currentPageSize)
                                    .Take(currentPageSize)
                                    .ToList();
                    totalManagerModels = managers.Count(c => c.Name.ToLower().Contains(filter));
                }
                else
                {
                    managerModels =
                        managers.Select(x => x.ToManagerModel())
                        .OrderBy(c => c.Name)
                        .Skip(currentPage * currentPageSize)
                        .Take(currentPageSize)
                        .ToList();
                    totalManagerModels = managers.Count();
                }
                result.Data = new PageModel <ManagerModel>
                {
                    Page       = currentPage,
                    TotalCount = totalManagerModels,
                    TotalPages = (int)Math.Ceiling((decimal)totalManagerModels / currentPageSize),
                    Items      = managerModels
                };
            }
            catch (Exception ex)
            {
                result.Status  = -1;
                result.Message = ex.Message;
                Logger.WriteErrorLog("CustomerService", "Search", ex);
            }
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Get People
        /// </summary>
        /// <returns></returns>
        public IEnumerable <PersonDto> Get()
        {
            var people = new List <PersonDto>();

            //Customers
            Mapper.CreateMap <Customer, PersonDto>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(src => src.LastName))
            .ForMember(dest => dest.DateOfBirth, opt => opt.MapFrom(src => src.DateOfBirth))
            .ForMember(dest => dest.PersonType, opt => opt.UseValue(PersonType.Customer));

            var customers = Mapper.Map <IEnumerable <Customer>, List <PersonDto> >(CustomerRepository.GetAll());

            people.AddRange(customers);

            //Employees
            Mapper.CreateMap <Employee, PersonDto>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(src => src.LastName))
            .ForMember(dest => dest.DateOfBirth, opt => opt.MapFrom(src => src.DateOfBirth))
            .ForMember(dest => dest.PersonType, opt => opt.UseValue(PersonType.Employee));

            var employees = Mapper.Map <IEnumerable <Employee>, List <PersonDto> >(EmployeeRepository.GetAll());

            people.AddRange(employees);

            //Managers
            Mapper.CreateMap <Manager, PersonDto>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(src => src.LastName))
            .ForMember(dest => dest.DateOfBirth, opt => opt.MapFrom(src => src.DateOfBirth))
            .ForMember(dest => dest.PersonType, opt => opt.UseValue(PersonType.Manager));

            var managers = Mapper.Map <IEnumerable <Manager>, List <PersonDto> >(ManagerRepository.GetAll());

            people.AddRange(managers);

            //Sales People
            Mapper.CreateMap <SalesPerson, PersonDto>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(src => src.LastName))
            .ForMember(dest => dest.DateOfBirth, opt => opt.MapFrom(src => src.DateOfBirth))
            .ForMember(dest => dest.PersonType, opt => opt.UseValue(PersonType.SalesPerson));

            var salesPeople = Mapper.Map <IEnumerable <SalesPerson>, List <PersonDto> >(SalesPersonRepository.GetAll());

            people.AddRange(salesPeople);

            return(people);
        }
Ejemplo n.º 6
0
        public bool isFoundInManagers(string email, string ucin, T user)
        {
            String             path = bingPathToAppDir(@"JsonFiles\manager.json");
            ManagerRepository  managerRepository = new ManagerRepository(path);
            List <ManagerUser> listOfManagers    = managerRepository.GetAll();

            foreach (ManagerUser manager in listOfManagers)
            {
                if (!areIDsEqual(manager.id, user.id) && (areUCINsEqual(manager.uniqueCitizensidentityNumber, ucin) || areEmailsEqual(manager.email, email)))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 7
0
        public List <Manager> GetAll()
        {
            var users = ManagerRepository.GetAll();

            if (users == null)
            {
                throw new BadRequestException(ErrorMessages.UserNoEncontrado);
            }

            var result     = new List <Manager>();
            var enumerator = users.GetEnumerator();

            while (enumerator.MoveNext())
            {
                result.Add(enumerator.Current);
            }
            return(result);
        }
Ejemplo n.º 8
0
 public List <Manager> GetAll()
 {
     return(ManagerRepository.GetAll().ToList());
 }
Ejemplo n.º 9
0
 public override List <ManagerUser> GetAll()
 {
     return(managerRepository.GetAll());
 }
Ejemplo n.º 10
0
 public Form1()
 {
     this.Repository = new ManagerRepository();
     InitializeComponent();
     ManagersGrid.DataSource = Repository.GetAll();
 }
Ejemplo n.º 11
0
        public void ManagerRetrieveAllTest()
        {
            var managers = ManagerRepository.GetAll();

            Assert.IsNotNull(managers);
        }
Ejemplo n.º 12
0
        public IEnumerable <ManagerDTO> GetManagers()
        {
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Manager, ManagerDTO>()).CreateMapper();

            return(mapper.Map <IEnumerable <Manager>, List <ManagerDTO> >(_managerRepository.GetAll()));
        }
Ejemplo n.º 13
0
 public IEnumerable <Manager> GetAll()
 {
     return(_managerRepository.GetAll());
 }
Ejemplo n.º 14
0
 public IEnumerable <Manager> GetAll()
 => _managerRepository.GetAll();
Ejemplo n.º 15
0
 public async Task <List <Manager> > Get()
 {
     // Getting all records from the Manager table
     return(await _repository.GetAll());
 }