public IEnumerable<Client> UseClientRepository() { var repository = new ClientRepository(); return repository .FindAllBy(x => x.Name.Contains("111")) .ToList(); }
private static async Task<AuthClient> GetClient(string clientId) { using (var repository = new ClientRepository()) { return await repository.GetClientAsync(clientId); }; }
public static void Clear() { IRepository<Client> _clientRepository = new ClientRepository(); IRepository<Product> _productRepository = new ProductRepository(); IRepository<Manager> _managerRepository = new ManagerRepository(); IEnumerable<Client> clientRepository = _clientRepository.GetItems(); IEnumerable<Product> productRepository = _productRepository.GetItems(); IEnumerable<Manager> managerRepository = _managerRepository.GetItems(); foreach (var item in clientRepository) { _clientRepository.Remove(item); } foreach (var item in productRepository) { _productRepository.Remove(item); } foreach (var item in managerRepository) { _managerRepository.Remove(item); } }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); Initer.Init(@"Server=ADWA;Database=Hotel;Trusted_Connection=true"); var clientData = new ClientData("test", "test", "test", "test"); var client = new Client { ClientData = clientData }; var repo = new ClientRepository(); repo.Save(client); var features = new List<Feature>(); features.Add(Feature.Bathroom); var room = new Room { Quality = RoomQuality.Average, Features = features, Type = RoomType.HotelRoom }; room.SetCapacity(5); var roomRepo = new RoomRepository(); roomRepo.Save(room); var features2 = new List<Feature>(); features2.Add(Feature.Bathroom); features2.Add(Feature.Tv); var room2 = new Room { Quality = RoomQuality.Good, Features = features2, Type = RoomType.HotelRoom }; room2.SetCapacity(2); roomRepo.Save(room2); var duration = new DayDuration(DateTime.Now, DateTime.Now.AddDays(1)); var reservation = new Reservation(client, room, duration); var reservationRepo = new ReservationRepository(); reservationRepo.Save(reservation); }
public void GetFirstCustomerStartWithTest() { var target = new ClientRepository(_unitOfWork); const string start = "a"; var actual = target.GetFirstCustomerStartWith(start); Assert.AreNotEqual(null, actual); }
public void DeleteClient(string clientId) { //unitOfWork.StartTransaction(); ClientRepository repo = new ClientRepository(unitOfWork); repo.Delete(x=>x.ClientId== clientId); //unitOfWork.Commit(); }
///<Summary> /// Gets the answer ///</Summary> public SmallBalanceJob() : base() { _jobsinfoRep = new JobsInfoRepository(); _paymantsRep = new PaymantsRepository(); _clientRep = new ClientRepository(); _sendemailjobinfoRep = new SendEmailJobInfoRepository(); }
public void TestClient() { var repo = new ClientRepository(); var results = repo.FindAll() .Where(a => a.LastName == " DiPasquale"); var count = results.Count(); Assert.IsTrue(count == 1); }
public void Before_each_test() { clientLicenseRepoistory = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); clientLicenseService = new ClientLicenseService(clientLicenseRepoistory); serviceProductsRepository = new ServiceProductsRepository(new ScutexServiceEntities()); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); objectSerializationProvider = new ObjectSerializationProvider(); numberDataGenerator = new NumberDataGenerator(); packingService = new PackingService(numberDataGenerator); commonRepository = new CommonRepository(new ScutexServiceEntities()); clientRepository = new ClientRepository(new ScutexServiceEntities()); keyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); masterService = new MasterService(commonRepository); activationLogRepository = new ActivationLogRepoistory(new ScutexServiceEntities()); activationLogService = new ActivationLogService(activationLogRepository, hashingProvider); keyService = new KeyManagementService(clientRepository, licenseKeyService, activationLogService, hashingProvider, serviceProductsRepository); commonService = new CommonService(); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Replace("file:\\", ""); var mockCommonService = new Mock<ICommonService>(); mockCommonService.Setup(common => common.GetPath()).Returns(path + "\\Data\\Client\\"); string masterServiceDataText; using (TextReader reader = new StreamReader(path + "\\Data\\MasterService.dat")) { masterServiceDataText = reader.ReadToEnd().Trim(); } masterServiceData = objectSerializationProvider.Deserialize<MasterServiceData>(masterServiceDataText); var mockCommonRepository = new Mock<ICommonRepository>(); mockCommonRepository.Setup(repo => repo.GetMasterServiceData()).Returns(masterServiceData); keyPairService = new KeyPairService(mockCommonService.Object, mockCommonRepository.Object); controlService = new ControlService(symmetricEncryptionProvider, keyPairService, packingService, masterService, objectSerializationProvider, asymmetricEncryptionProvider); servicesRepository = new ServicesRepository(new ScutexEntities()); serviceStatusProvider = new ServiceStatusProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider); licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); servicesService = new ServicesService(servicesRepository, serviceStatusProvider, packingService, licenseActiviationProvider, null, null, null, null, null); licenseKeyService = new LicenseKeyService(keyGenerator, packingService, clientLicenseService); activationService = new ActivationService(controlService, keyService, keyPairService, objectSerializationProvider, asymmetricEncryptionProvider, null, null); string serviceData; using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat")) { serviceData = reader.ReadToEnd().Trim(); } service = objectSerializationProvider.Deserialize<Service>(serviceData); }
public DAO() { Log.Trace("DAO start creating."); Context = new StoreContext(); ClientRepository = new ClientRepository(Context); GoodsRepository = new GoodsRepository(Context); ManagerRepository = new ManagerRepository(Context); SaleRepository = new SaleRepository(Context); Log.Trace("DAO created."); }
public ClientModel SaveClient(ClientModel model) { //unitOfWork.StartTransaction(); ClientRepository repo = new ClientRepository(unitOfWork); Client client = new Client(); AutoMapper.Mapper.Map(model, client); repo.Insert(client); //unitOfWork.Commit(); AutoMapper.Mapper.Map(client, model); return model; }
public void RememberClientTest() { IRepository<Client> _clientRepository = new ClientRepository(); Program.ClearInformation(); Client client = new Client(2, "Petr Petrov"); _clientRepository.Add(client); Client actual = _clientRepository.GetItem(client.id); Assert.AreEqual(client.id, actual.id); Assert.AreEqual(client.name, actual.name); Program.ClearInformation(); }
public RequestRepository() { _clientRepository = new ClientRepository(); _itemRepository = new ItemRepository(); _unitOfIssueRepository = new UnitRepository(); _modeService = new ModeService(); _paymentTermService = new PaymentTermRepository(); _orderStatusService = new OrderStatusService(); _manufacturerRepository = new ManufacturerRepository(); _physicalStoreRepository = new PhysicalStoreRepository(); _activityRepository = new ActivityRepository(); }
public List<ClientModel> GetAllClients() { //unitOfWork.StartTransaction(); ClientRepository repo = new ClientRepository(unitOfWork); List<ClientModel> clientList = new List<ClientModel>(); List<Client> client = new List<Client>(); AutoMapper.Mapper.Map(clientList, client); client = repo.GetAll().ToList(); //unitOfWork.Commit(); AutoMapper.Mapper.Map(client, clientList); return clientList; }
public static void ConfigureClients(IEnumerable<Client> clients, DocumentDbServiceOptions options) { ClientRepository clientRepository = new ClientRepository(options.ToConnectionSettings()); var allClients = clientRepository.GetAllClients().Result; if (!allClients.Any()) { foreach (var c in clients) { clientRepository.AddClient(c.ToDocument()).Wait(); } } }
static void Main(string[] args) { //Database.SetInitializer(new DropCreateDatabaseAlways<MyContext>()); var uow = new UnitOfWork(new MyContext()); var clientRepository = new ClientRepository(uow); CriarCliente(clientRepository); uow.Dispose(); Console.ReadKey(); }
public void CollectionInsertTest() { var customer = new Client {Name = "Customer-LazyLoad", Family = "CustomerA1"}; var ClientRepository = new ClientRepository(_unitOfWork); ClientRepository.Add(customer); var account1 = new Account {Client = customer, Balance = 10, OpendedDate = DateTime.Now}; var account2 = new Account {Client = customer, Balance = 100, OpendedDate = DateTime.Now}; customer.Accounts = new Collection<Account> {account1, account2}; _unitOfWork.Commit(); customer = ClientRepository.FindByID(customer.ClientID); Assert.AreEqual(2, customer.Accounts.Count); }
public ClientModel GetClientById(string clientId) { //unitOfWork.StartTransaction(); ClientRepository repo = new ClientRepository(unitOfWork); ClientModel clientModel = new ClientModel(); Client client = new Client(); AutoMapper.Mapper.Map(clientModel, client); client = repo.GetAll().Where(x => x.ClientId == clientId).FirstOrDefault(); //unitOfWork.Commit(); AutoMapper.Mapper.Map(client, clientModel); return clientModel; }
public TestMongoRepository(string db_name) { getDatabase(db_name); this.cr = new ClientRepository(db); this.br = new BookRepository(db); this.or = new OrderRepository(db); Fill(); //View(); //Clear(); }
public void IsExistingClientTest() { Program.ClearInformation(); IRepository<Client> _clientRepository = new ClientRepository(); _clientRepository.Add(new Client(1, "Ivan Ivanov")); IEnumerable<Client> clientRepository = _clientRepository.GetItems(); Client client = new Client(2, "Petr Petrov"); bool expected = false; bool actual = Realtor.IsExistingClient(clientRepository, client.name); Assert.AreEqual(expected, actual); Program.ClearInformation(); }
public static int AddClient(Client client) { ClientRepository clientRepository = new ClientRepository(); try { return clientRepository.GetAll().Where(_client => _client.name.Split(' ')[0] == client.name).First().id; } catch { new ClientRepository().Add(client); return client.id; } }
static void AutoFilling() { Product[] product = new Product[10]; Client[] client = new Client[10]; Manager[] manager = new Manager[10]; product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale"); product[1] = new Product(2, "Office", "MOPRa, 30", "for sale"); product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale"); product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale"); product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale"); product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale"); product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale"); product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale"); product[8] = new Product(9, "House", "Lugivaja, 11", "for sale"); product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale"); client[0] = new Client(1, "Fedor Dvinyatin"); client[1] = new Client(2, "Alexei Volkov"); client[2] = new Client(3, "Ivan Ivanov"); client[3] = new Client(4, "Petr Bojko"); client[4] = new Client(5, "Egor Valedinsky"); client[5] = new Client(6, "Alexander Evtuh"); client[6] = new Client(7, "Alexei Lohnitsky"); client[7] = new Client(8, "Mokin Alexander"); client[8] = new Client(9, "Pavlovets Sergey"); client[9] = new Client(10, "Igor Pujko"); manager[0] = new Manager(1, "Viktor Oniskevich"); manager[1] = new Manager(2, "Petr Glinskij"); manager[2] = new Manager(3, "Fedor Yakubuk"); manager[3] = new Manager(4, "Vasily Sapon"); manager[4] = new Manager(5, "Igor Ivanovskiy"); manager[5] = new Manager(6, "Alexander Dubrovsky"); manager[6] = new Manager(7, "Olga Golub"); manager[7] = new Manager(8, "Egor Pirozhkov"); manager[8] = new Manager(9, "Boris Zhukovich"); manager[9] = new Manager(10, "Igor Stepanchuk"); IRepository<Client> _clientRepository = new ClientRepository(); IRepository<Product> _productRepository = new ProductRepository(); IRepository<Manager> _managerRepository = new ManagerRepository(); for (int i=0 ; i<=9 ; i++) { _clientRepository.Save(client[i]); _productRepository.Save(product[i]); _managerRepository.Save(manager[i]); } }
public bool CheckExistance(string clientId ) { //unitOfWork.StartTransaction(); ClientRepository repo = new ClientRepository(unitOfWork); var client = repo.GetAll().Where(x => x.ClientId == clientId).Count(); //unitOfWork.Commit(); if (client > 0) { return true; } else { return false; } }
public MainWindow() { InitializeComponent(); model = new EzBillingModel(); clientRepository = new ClientRepository(model); companyRepository = new CompanyRepository(model); billRepository = new BillRepository(model); excelConnection = new ExcelConnection(); billManager = new BillManager(); clientWindow = new clientWindow(clientRepository, billRepository, billManager); companyWindow = new companyWindow(companyRepository, billRepository, billManager); clientWindow.Closing += new CancelEventHandler(window_Closing); companyWindow.Closing += new CancelEventHandler(window_Closing); ClientViewModel = new InformationWindowViewModel<Client>(); ClientViewModel.Items = new ObservableCollection<Client>(clientRepository.All.ToList()); CompanyViewModel = new InformationWindowViewModel<Company>(); CompanyViewModel.Items = new ObservableCollection<Company>(companyRepository.All.ToList()); CompanyViewModel.PropertyChanged += CompanyViewModel_PropertyChanged; ProductViewModel = new InformationWindowViewModel<Product>(); ProductViewModel.Items = new ObservableCollection<Product>(); ProductViewModel.PropertyChanged += ProductViewModel_PropertyChanged; BillViewModel = new InformationWindowViewModel<Bill>(); BillViewModel.Items = new ObservableCollection<Bill>(); BillViewModel.PropertyChanged += BillViewModel_PropertyChanged; this.Closing += MainWindow_Closing; productSectionInputFields = new TextBox[] { productName_TextBox, productQuantity_TextBox, productUnit_TextBox, productUnitPrice_TextBox, productVATPercent_TextBox }; DataContext = this; excelConnection.Open(); }
public void ClientRepositoryTest() { ClientRepository repository = new ClientRepository(); Client expectedClient = new Client { name = "clientsomeclient" }; repository.Add(expectedClient); Client realClient = repository.GetAll().Last(); Assert.AreEqual(expectedClient, realClient); repository.Delete(realClient); realClient = repository.GetAll().Last(); Assert.AreNotEqual(expectedClient.name, realClient.name); }
public void ClientRepositoryTest() { ClientRepository repository = new ClientRepository(); Client expectedClient = new Client(repository.GetAll().Count() + 1, "clientsomeclient"); repository.Add(expectedClient); Client realClient = repository.GetItem(expectedClient.id); Assert.AreEqual(expectedClient, realClient); repository.Delete(expectedClient); realClient = repository.GetItem(expectedClient.id); Assert.AreEqual(null, realClient); }
public void InsertDeleteAndUpdateTest() { var ClientRepository = new ClientRepository(_unitOfWork); Client customer = ClientRepository.FindByID(10); customer.Name = "Updated"; ClientRepository.Update(customer); var accountRepository = new AccountRepository(_unitOfWork); var accountList = accountRepository.GetCustomerAccounts(customer.ClientID); foreach (var account in accountList) { accountRepository.Remove(account); } _unitOfWork.Commit(); var deletedAccountList = accountRepository.GetCustomerAccounts(customer.ClientID); Assert.AreEqual(0, deletedAccountList.Count); }
public ActionResult MakeContract(MakeContractModel contract) { Clients client; //если клиент с таким именем уже существует, то берем его //если нет то создаем новый try { client = new ClientRepository() .GetAll() .Where(x => x.name.TrimEnd() == contract.clientName).First(); } catch { //создаем клиента client = new Clients { name = contract.clientName }; } Projects project = new Projects { description = contract.projectDescription, name = contract.projectName, deadline = DateTime.Now.AddDays(20.0) }; Agents agent = new AgentRepository().GetAll().Where(x => x.name.TrimEnd() == contract.agentName).First(); Builders builder = new BuilderRepository().GetAll().Where(x => x.name.TrimEnd() == contract.builderName).First(); Contracts contractToAdd = new Contracts() { agentId = agent.id, builderId = builder.id, clientId = client.id, Clients = client, projectId = project.id, Projects = project }; new ContractRepository().Save(contractToAdd); return RedirectToAction("Index"); }
public async Task AllAsync_ShouldReturnAllClients_UsingMoq() { var data = new List<ClientSupplier> { new ClientSupplier { ClientID = 1 }, new ClientSupplier { ClientID = 2 }, new ClientSupplier { ClientID = 3 } }.AsQueryable(); var mockSet = new Mock<DbSet<ClientSupplier>>(); mockSet.As<IDbAsyncEnumerable<ClientSupplier>>() .Setup(m => m.GetAsyncEnumerator()) .Returns(new FakeDbAsyncEnumerator<ClientSupplier>(data.GetEnumerator())); mockSet.As<IQueryable<ClientSupplier>>() .Setup(m => m.Provider) .Returns(new FakeDbAsyncQueryProvider<ClientSupplier>(data.Provider)); mockSet.As<IQueryable<ClientSupplier>>().Setup(m => m.Expression).Returns(data.Expression); mockSet.As<IQueryable<ClientSupplier>>().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As<IQueryable<ClientSupplier>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); var mockContext = new Mock<IClientContext<ClientContext>>(); mockContext.Setup(c => c.ClientSuppliers).Returns(mockSet.Object); var uow = new Mock<IUnitOfWork<ClientContext>>(); uow.Setup(x => x.Context).Returns(mockContext.Object); _repository = new ClientRepository(uow.Object); var result = await _repository.AllAsync(); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count); Assert.AreEqual(1, result[0].ClientID); Assert.AreEqual(2, result[1].ClientID); Assert.AreEqual(3, result[2].ClientID); }
public async Task AllAsync_ShouldReturnAllClients_UsingFakes() { var context = new FakeClientContext(); context.ClientSuppliers.Add(new ClientSupplier { ClientID = 1 }); context.ClientSuppliers.Add(new ClientSupplier { ClientID = 2 }); context.ClientSuppliers.Add(new ClientSupplier { ClientID = 3 }); var uow = new Mock<IUnitOfWork<ClientContext>>(); uow.Setup(x => x.Context).Returns(context); _repository = new ClientRepository(uow.Object); var result = await _repository.AllAsync(); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count); Assert.AreEqual(1, result[0].ClientID); Assert.AreEqual(2, result[1].ClientID); Assert.AreEqual(3, result[2].ClientID); }
public FifthForm() { InitializeComponent(); _querySession = new ClientRepository(); }
/// <summary> /// Initializes a new instance of the <see cref="RestApp.Controllers.ClientsController"/> class. /// </summary> public ClientsController() { _repository = new ClientRepository(); }
public static int DeleteClient(Client client) { return(ClientRepository.DeleteClient(client)); }
/// <summary> /// 编辑客户端信息 /// </summary> /// <param name="dto">客户端信息输入DTO</param> /// <returns>业务操作结果</returns> public virtual Task <OperationResult> UpdateClient(TClientInputDto dto) { dto.CheckNotNull("dto"); return(ClientRepository.UpdateAsync(new[] { dto })); }
public OrderWorkplace(ClientRepository clientRepository) { clientDB = clientRepository; workplaceDB = new WorkplaceRepository(); workplaceOrderDB = new WorkplaceOrderRepository(); }
public ClientController(ApplicationDbContext context, IConfiguration configuration) { _clientRepository = new ClientRepository(context); _userRepository = new UserRepository(context, configuration); }
public async Task <List <ClientModel> > GetClients([FromServices] RhNetContext rhNetContext, [FromServices] UserManager <ApplicationUser> userManager) { ClientRepository repository = new ClientRepository(); return(await repository.GetClients(rhNetContext, userManager, this.User.Identity.Name)); }
public ClientsController() { this._clientRepository = new ClientRepository(new HotelReservationsManagerDb()); }
public static void AutoFilling() { Product[] product = new Product[10]; Client[] client = new Client[10]; Manager[] manager = new Manager[10]; product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale"); product[1] = new Product(2, "Office", "MOPRa, 30", "for sale"); product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale"); product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale"); product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale"); product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale"); product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale"); product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale"); product[8] = new Product(9, "House", "Lugivaja, 11", "for sale"); product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale"); client[0] = new Client(1, "Fedor Dvinyatin"); client[1] = new Client(2, "Alexei Volkov"); client[2] = new Client(3, "Ivan Ivanov"); client[3] = new Client(4, "Petr Bojko"); client[4] = new Client(5, "Egor Valedinsky"); client[5] = new Client(6, "Alexander Evtuh"); client[6] = new Client(7, "Alexei Lohnitsky"); client[7] = new Client(8, "Mokin Alexander"); client[8] = new Client(9, "Pavlovets Sergey"); client[9] = new Client(10, "Igor Pujko"); manager[0] = new Manager(1, "Viktor Oniskevich"); manager[1] = new Manager(2, "Petr Glinskij"); manager[2] = new Manager(3, "Fedor Yakubuk"); manager[3] = new Manager(4, "Vasily Sapon"); manager[4] = new Manager(5, "Igor Ivanovskiy"); manager[5] = new Manager(6, "Alexander Dubrovsky"); manager[6] = new Manager(7, "Olga Golub"); manager[7] = new Manager(8, "Egor Pirozhkov"); manager[8] = new Manager(9, "Boris Zhukovich"); manager[9] = new Manager(10, "Igor Stepanchuk"); IRepository <Client> _clientRepository = new ClientRepository(); IRepository <Product> _productRepository = new ProductRepository(); IRepository <Manager> _managerRepository = new ManagerRepository(); IEnumerable <Client> clientRepository = _clientRepository.GetItems(); IEnumerable <Product> productRepository = _productRepository.GetItems(); IEnumerable <Manager> managerRepository = _managerRepository.GetItems(); foreach (var item in clientRepository) { _clientRepository.Remove(item); } foreach (var item in productRepository) { _productRepository.Remove(item); } foreach (var item in managerRepository) { _managerRepository.Remove(item); } for (int i = 0; i <= 9; i++) { _clientRepository.Add(client[i]); _productRepository.Add(product[i]); _managerRepository.Add(manager[i]); } }
public async Task <ActionResult <dynamic> > Login([FromServices] UserManager <ApplicationUser> userManager, [FromServices] RoleManager <ApplicationRole> roleManager, [FromServices] RhNetContext rhNetContext, [FromBody] LoginModel model) { ApplicationUser user = await userManager.FindByNameAsync(model.Username); if (user == null) { if (model.Username == "master" && model.Password == "Mm123456*") { await userManager.CreateAsync(new ApplicationUser() { Email = "*****@*****.**", UserName = "******", Cpf = "11111111111" }, "Mm123456*"); user = await userManager.FindByNameAsync(model.Username); await roleManager.CreateAsync(new ApplicationRole() { Name = "Master", Description = "Acesso Total ao sistema. Pode cadastrar novos usuários, clientes e empresas." }); await roleManager.CreateAsync(new ApplicationRole() { Name = "Administrador", Description = "Acesso e cadastro das tabelas em comum do sistema. Pode cadastrar Super Usuários." }); await roleManager.CreateAsync(new ApplicationRole() { Name = "Super Usuário", Description = "Cadastra Usuário do RH." }); await roleManager.CreateAsync(new ApplicationRole() { Name = "RH", Description = "Cadastra funcionários, atualiza dados dos funcionários e tabelas específicas." }); await roleManager.CreateAsync(new ApplicationRole() { Name = "Gestor Mediato", Description = "Responsável por autorizar as solicitações do Superior Mediato." }); await roleManager.CreateAsync(new ApplicationRole() { Name = "Gestor Imediato", Description = "Responsável por autorizar as solicitações de seus suborinados, lançamento de férias, entre outros." }); await roleManager.CreateAsync(new ApplicationRole() { Name = "Funcionário", Description = "Consulta informações próprias no sistema, entre outros." }); await userManager.AddToRoleAsync(user, "Master"); await userManager.AddToRoleAsync(user, "Administrador"); await userManager.AddToRoleAsync(user, "Super Usuário"); await userManager.AddToRoleAsync(user, "RH"); await userManager.AddToRoleAsync(user, "Gestor Mediato"); await userManager.AddToRoleAsync(user, "Gestor Imediato"); await userManager.AddToRoleAsync(user, "Funcionário"); } else { return(StatusCode((int)HttpStatusCode.BadRequest, "Usuário não cadastrado.")); } } bool isValid = await userManager.CheckPasswordAsync(user, model.Password); if (!isValid) { return(StatusCode((int)HttpStatusCode.BadRequest, "Senha incorreta.")); } UserRepository repository = new UserRepository(); var clients = await repository.GetClientsAsync(rhNetContext, user.Id); if (clients.Count() == 0) { if (user.UserName == "master") { ClientRepository clientRepository = new ClientRepository(); clients = await clientRepository.GetAllClients(rhNetContext); } else { return(BadRequest("Cliente não associado a um cliente")); } } if (clients.Count() > 1 && model.SelectedClient == null) { return(StatusCode((int)HttpStatusCode.Conflict, clients)); } ClientModel selectedClient = null; if (clients.Count() == 1) { selectedClient = clients[0]; } else { for (var i = 0; i < clients.Count; i++) { if (model.SelectedClient.Cnpj == clients[i].Cnpj) { selectedClient = clients[i]; break; } } } if (selectedClient == null) { return(BadRequest("Cliente não associado a um cliente ou cliente selecionado incorreto")); } if (selectedClient.Situation == Enums.ClientSituation.Bloqueado && user.UserName != "master") { return(BadRequest("Cliente bloqueado. Entre em contato com um administrador do sistema")); } if (selectedClient.Situation == Enums.ClientSituation.Inativo && user.UserName != "master") { return(BadRequest("Cliente inativo. Entre em contato com um administrador do sistema")); } var profiles = (await repository.GetRolesAsync(userManager, rhNetContext, user.UserName, selectedClient.Id)).ToList(); var claims = (await repository.GetClaimsAsync(userManager, rhNetContext, user.UserName, selectedClient.Id)).ToList(); // Gera o Token var token = TokenService.GenerateToken(user, profiles, claims); var loginUser = new UserModel() { Username = user.UserName, Email = user.Email, Token = token, Profiles = profiles, CurrentClient = selectedClient }; return(StatusCode((int)HttpStatusCode.OK, loginUser)); }
public TaskStatusController() { Repository = new ClientRepository(); }
public static ClientCollection GetClients() { return(ClientRepository.GetClients()); }
public static int DeleteClient(Client client) => ClientRepository.DeleteClient(client);
public TaskOriginController() { Repository = new ClientRepository(); }
static void Main(string[] args) { InsuranceHandler insuranceHandler = new InsuranceHandler(); ClientRepository clientRepository = new ClientRepository(); ProductRepository productRepository = new ProductRepository(); Console.WriteLine("Please enter one of client's names -> Anna or Juris or Zinta"); Console.WriteLine(" "); string name = Console.ReadLine(); Client clientsClient = clientRepository.GetClientByName(name); Console.WriteLine($"You selected Client is -> {clientsClient.Name}, {clientsClient.Surname}, {clientsClient.SocialSecurityNumber}, {clientsClient.Sex}, {clientsClient.Address}"); Console.WriteLine(" "); Console.WriteLine("Please enter product id -> 1 or 2 or 3"); Console.WriteLine(" "); string id = Console.ReadLine(); Product product = productRepository.GetProductById(id: id); Console.WriteLine($"Your selected Product is {product.ProductName}, cost -> {product.Premium}"); Console.WriteLine(" "); decimal premiumResult = insuranceHandler.GetPrice(client: clientsClient, productId: product); //Console.WriteLine("Your selected Product Premium is -> {0}", premiumResult); string policyNumber = insuranceHandler.GetPolicy(client: clientsClient, productId: product); //Console.WriteLine("Your Policy number is -> {0}", policyNumber); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine("OFFER: -> {0}'s {1} Policy Premium will be {2} ", name, product.ProductName, premiumResult); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine(" "); Policy policy = insuranceHandler.GetPolicyData(client: clientsClient, productId: product); //Console.WriteLine($"Policy start date = {policy.StartDate}, end date = {policy.EndDate}, state = {policy.State}, client = {policy.Client}"); Console.WriteLine("If you would like to buy this Policy , then write -> Y "); Console.WriteLine(" "); string answer = Console.ReadLine(); if (answer == "Y") { //BuyInsurance will change state to Active and call SavePolicy method Policy policy1 = insuranceHandler.BuyInsurance(client: clientsClient, productId: product); //Policy presentation Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine($"Your client '{clientsClient.Name.ToUpper()} {clientsClient.Surname.ToUpper()}' bought '{product.ProductName}' Policy and Policy details are:"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); Console.WriteLine($"Policy Number = {policy1.PolicyNumber}, "); Console.WriteLine($"Start date = {policy1.StartDate}"); Console.WriteLine($"End date = {policy1.EndDate}"); Console.WriteLine($"client name = {policy1.Client}"); Console.WriteLine($"State = {policy1.State.ToUpper()}"); // Console.WriteLine($"client = {policy1.Client}, State = {policy1.State}, Start date = {policy1.StartDate}, End date = {policy1.EndDate}"); Console.ReadKey(); } else { Console.WriteLine("See you next time!"); } Console.ReadKey(); //parbauda, vai stuss ir draft // izsauc metodi buyinsurance, //atrod polisi, parbauda vai statuss ir active //pietrukst: // 1. getprice metode jaatgriez policy tips // 2. test piemera cenu jaizgust no polises }
public static ClientCollection GetAllClients() => ClientRepository.GetAllClients();
public ClientController() { Repository = new ClientRepository(); }
public async Task <List <ClientModel> > GetAllClients([FromServices] RhNetContext rhNetContext) { ClientRepository repository = new ClientRepository(); return(await repository.GetAllClients(rhNetContext)); }