public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,ClientEmail,Street,Town,PostalCode,Voivodeship,Country, ownerID")] ClientsViewModel client) { if (id != client.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ClientMapper.MapViewToClient(client)); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(client.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(client)); }
public List <PublicModel.ClientPub> GetClients() { using (var context = new Model.CarRentContext()) { return(context.Clients.Select(x => ClientMapper.ToPublicModel(x)).ToList()); } }
public IActionResult Create() { var mappedClients = ClientMapper.MapManyToViewModel(clientService.GetClients()); var mappedOrders = OrderMapper.MapManyToViewModel(orderService.GetOrders()); return(View(new InvoiceCreateViewModel(mappedClients, mappedOrders))); }
public IEnumerable <ClientData> GetAllClients() { ClientMapper clientMapper = new ClientMapper(); IEnumerable <ClientData> clients = clientMapper.GetAll(); return(clients); }
private void searchClientButton_Click(object sender, EventArgs e) { clientsFoundListBox.Items.Clear(); clientCarsLabel.Visible = false; bool containsResults = false; List <Client> foundClients = new List <Client>(sessionData.clientRepository.PartialSearchClients(clientFirstNameInput.Text, clientLastNameInput.Text)); foreach (var client in foundClients) { if (client.Nume.ToLower().StartsWith(clientFirstNameInput.Text.ToLower())) { containsResults = true; } } if (containsResults == true) { foreach (var client in foundClients) { if (client.Nume.ToLower().StartsWith(clientFirstNameInput.Text.ToLower())) { clientsFoundListBox.Items.Add(ClientMapper.fromEntityToModel(client)); } } clientsFoundListBox.Visible = true; modifyClientButton.Visible = true; deleteClientButton.Visible = true; } else { MessageBox.Show("No client found"); modifyClientButton.Visible = false; deleteClientButton.Visible = false; clientsFoundListBox.Visible = false; } }
private void clientsFoundListBox_SelectedIndexChanged(object sender, EventArgs e) { clientAutosListBox.Items.Clear(); sessionData.selectedClient = ClientMapper.fromModelToEntity((ClientModel)clientsFoundListBox.SelectedItem); if (sessionData.selectedClient == null) { clientCarsLabel.Visible = false; modifyAutoButton.Visible = false; deleteAutoButton.Visible = false; addAutoToClientButton.Visible = false; } else { var obtainedClient = sessionData.clientRepository.GetClient(sessionData.selectedClient.ClientId); if (obtainedClient != null) { clientCarsLabel.Visible = true; clientAutosListBox.Visible = true; modifyAutoButton.Visible = true; deleteAutoButton.Visible = true; addAutoToClientButton.Visible = true; List <Automobil> clientAutos = sessionData.clientRepository.GetAutosOfClient(obtainedClient); foreach (var auto in clientAutos) { if (!clientAutosListBox.Items.Contains(auto)) { clientAutosListBox.Items.Add(AutoMapper.FromEntityToModel(auto)); } } } } }
public void Generate() { WriteLine("#Start nat config generator"); using (var db = new ApplicationDbContext()) { var clients = db.Clients .Include(c => c.GreyAddress) .ThenInclude(g => g.White) .Where(c => !c.IsDeleted) .Where(c => c.GreyAddress != null) .Where(c => c.GreyAddress.White != null) .ToList(); clients.ForEach(c => { var status = ClientMapper.CalculateClientStatus(c); if (status != ClientStatus.Active) { WriteLine($"#{c.Login} state {status}"); return; } var grey = c.GreyAddress.Address; var white = c.GreyAddress.White.Address; WriteLine($"#2-way mapping for {c.Login}"); WriteLine($"/sbin/iptables -t nat -A PREROUTING -d {white} -j DNAT --to-destination {grey}"); WriteLine($"/sbin/iptables -t nat -A POSTROUTING -s {grey} -o eth0.52 -j SNAT --to-source {white}"); WriteLine(); }); } WriteLine("#End nat config generator"); }
public async Task <List <DAL.App.DTO.Client> > AllForClientGroupAsync(int?clientGroupId) { return(await RepositoryDbSet .Include(p => p.ClientGroup) .Where(p => p.ClientGroupId == clientGroupId) .Select(e => ClientMapper.MapFromDomain(e)) .ToListAsync()); }
public IActionResult Create() { var mappedEmployees = EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees()); var mappedClients = ClientMapper.MapManyToViewModel(clientService.GetClients()); var mappedProducts = ProductMapper.MapManyToViewModel(productService.GetProducts()); return(View(new OrderCreateViewModel(mappedEmployees, mappedClients, mappedProducts))); }
private void modifyClientButton_Click(object sender, EventArgs e) { sessionData.Operation_Type = OperationTypes.MODIFY_CLIENT; sessionData.selectedClient = ClientMapper.fromModelToEntity((ClientModel)clientsFoundListBox.SelectedItem); ClientPopupForm clientPopupForm = new ClientPopupForm(sessionData); clientPopupForm.Show(); }
public MappingContext(string connectionStringName) { string connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; clientMapper = new ClientMapper(connectionString); productMapper = new ProductMapper(connectionString); discountMapper = new DiscountMapper(connectionString); discountPoliciesMapper = new DiscountPoliciesMapper(connectionString); }
public async Task <ClientDto> Create(ClientDto dto) { var client = ClientMapper.Map(dto); await this.dbContext.Clients.AddAsync(client); await this.dbContext.SaveChangesAsync(); return(ClientDtoMapper.Map(client)); }
public static void Create(ClientDto dto) { using (var db = new MainDBModelContainer()) { var entity = ClientMapper.DtoToEntity(dto); db.ClientSet.Add(entity); db.SaveChanges(); } }
public ServicesHistoryController(IServicesHistoryRepository servicesHistoryRepository) { this.servicesHistoryRepository = new ServiceHistoryRepository(); this.serviceHistoryMapper = new ServicesHistoryMapper(); clientRepository = new ClientRepository(); clientMapper = new ClientMapper(); serviceHistoryRepository = new ServiceHistoryRepository(); branchRepository = new BranchRepository(); employeeRepository = new EmployeeRepository(); servicesDirectoryRepository = new ServiceDirectoryRepository(); }
public async Task <IActionResult> GetClientById(int id) { var client = await _clientService.GetClientById(id); if (client != null) { var resp = ClientMapper.MapUserDetailsToDto(client, _clientService); return(Ok(resp)); } return(Ok(client)); }
public static ClientDto Read(int id) { using (var db = new MainDBModelContainer()) { var data = db.ClientSet.Find(id); if (data != null) { return(ClientMapper.EntityToDto(data)); } throw new ElementNotFoundException(); } }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,ClientEmail,Street,Town,PostalCode,Voivodeship,Country,ownerID")] ClientsViewModel client) { if (ModelState.IsValid) { client.ownerID = HttpContext.Session.GetObjectFromJson <int>("ownerID"); _context.Add(ClientMapper.MapViewToClient(client)); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(client)); }
public async Task <ModelStatistics> Train(string schemaName, CancellationToken cancellationToken, params TableDefinition[] tables) { var tableStore = _tableStoreFactory.Create(schemaName); var data = await GetDataRowsAsync(tableStore, tables.First().Name, cancellationToken); var calculatedScores = _rfmCalculateService.CalculateRfmScores(ClientMapper.MapToClients(data)); return(new RfmStatistics { Clients = calculatedScores }); }
public async Task <IActionResult> Index() { bool isAuthenticated = User.Identity.IsAuthenticated; if (isAuthenticated) { var clients = _context.Clients.Where(s => s.ownerID == HttpContext.Session.GetObjectFromJson <int>("ownerID")); return(View(ClientMapper.MapClientsListToView(clients, _context))); } return(RedirectToAction("Login", "Account", new { area = "" })); }
public async Task <ClientDto> Update(ClientDto dto) { var client = await dbContext.Clients .Include(x => x.Address) .Include(x => x.Rate) .Where(x => x.Id == dto.Id) .FirstAsync(); ClientMapper.MapUpdate(client, dto); await dbContext.SaveChangesAsync(); return(ClientDtoMapper.Map(client)); }
public IActionResult Details(int id) { if (id < 1) { return(BadRequest()); } try { var mappedEmployees = EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees()); if (mappedEmployees == null) { mappedEmployees = new List <EmployeeViewModel>(); } var mappedInvoices = InvoiceMapper.MapManyToViewModel(invoiceService.GetInvoices()); if (mappedInvoices == null) { mappedInvoices = new List <InvoiceViewModel>(); } var mappedProducts = ProductMapper.MapManyToViewModel(productService.GetProducts()); if (mappedProducts == null) { mappedProducts = new List <ProductViewModel>(); } var mappedProtocols = ProtocolMapper.MapManyToViewModel(protocolService.GetProtocols()); if (mappedProtocols == null) { mappedProtocols = new List <ProtocolViewModel>(); } var mappedClients = ClientMapper.MapManyToViewModel(clientService.GetClients()); if (mappedClients == null) { mappedClients = new List <ClientViewModel>(); } var order = orderService.GetOrderById(id); var mappedOrder = OrderMapper.MapToViewModel(order, order.Employee, order.Client, order.Product, order.Protocol, order.Invoice); var orderDetails = new OrderDetailsViewModel(mappedEmployees, mappedClients, mappedProducts, mappedProtocols, mappedInvoices, mappedOrder); return(View(orderDetails)); } catch (Exception ex) { return(NotFound(ex.Message)); } }
public async Task <IActionResult> GetAllClients() { var clients = await _clientService.GetAllAsync(); if (clients != null && clients.Any()) { var resp = new List <ClientResponseDTO>(); foreach (var client in clients) { resp.Add(ClientMapper.MapUserDetailsToDto(client, _clientService)); } return(Ok(resp)); } return(Ok(clients)); }
public async Task <IActionResult> SearchClient([FromQuery(Name = "searchStr")] string searchStr = "") { var searchResult = await _clientService.SearchClient(searchStr); if (searchResult != null && searchResult.Any()) { var resp = new List <ClientResponseDTO>(); foreach (var client in searchResult) { resp.Add(ClientMapper.MapUserDetailsToDto(client, _clientService)); } return(Ok(resp)); } return(Ok(searchResult)); }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var client = await _context.Clients .SingleOrDefaultAsync(m => m.ID == id); if (client == null) { return(NotFound()); } return(View(ClientMapper.MapClientToView(client, _context))); }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var client = await _context.Clients.SingleOrDefaultAsync(m => m.ID == id); if (client == null) { return(NotFound()); } PrepareVoivodeshipsAndCountires(); return(View(ClientMapper.MapClientToView(client, _context))); }
public static void Update(ClientDto dto) { using (var db = new MainDBModelContainer()) { var newData = ClientMapper.DtoToEntity(dto); var oldData = db.ClientSet.Find(dto.Id); if (oldData != null) { oldData.Name = newData.Name; oldData.Email = newData.Email; oldData.Phone = newData.Phone; db.SaveChanges(); } else { throw new ElementNotFoundException(); } } }
// GET: Clients/Edit/5 public ActionResult Edit(int?id) //éste método carga la vista de edición de un cliente existente { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Client client = db.Clients.Find(id); if (client == null) { return(HttpNotFound()); } var mapper = new ClientMapper(); var vm = mapper.ClientToClientViewModel(client); vm.CityList = GetCitySelectList(client.CityId); return(View(vm)); }
public void Test_insertJob() { var data = new EfData(); var client = data.GetClients().Where(c => c.Id == 4).FirstOrDefault(); var user = data.GetUsers().Where(c => c.Id == "60d9002e-667f-4794-a9dd-670c0ecf56c9").FirstOrDefault(); var st = data.GetTypes().Where(c => c.Id == 1).FirstOrDefault(); var client2 = ClientMapper.MapToClientDAO(client); var user2 = UserMapper.MapToUserDAO(user); var st2 = ServiceTypeMapper.MapToServiceTypeDAO(st); var j = new JobDAO(); j.Client = client2; j.User = user2; j.ServiceType = st2; var actual = AddJob(j); Assert.True(actual); }
private void autoSaveButton_Click(object sender, EventArgs e) { var clientChoosed = ClientMapper.fromModelToEntity((ClientModel)autoOwnersComboBox.SelectedItem); var chassisSelected = (ChassisModel)chassisComboBox.SelectedItem; if (clonnedSessionData.Operation_Type == OperationTypes.MODIFY_AUTO) { if (string.IsNullOrEmpty(registrationNumberTextBox.Text) || string.IsNullOrEmpty(chassisSeriesTextBox.Text) || clientChoosed == null || chassisSelected == null) { MessageBox.Show("Not all mandatory fields are filled"); return; } var autoToModify = clonnedSessionData.selectedAuto; autoToModify.AutoId = clonnedSessionData.selectedAuto.AutoId; autoToModify.NumarAuto = registrationNumberTextBox.Text; autoToModify.SerieSasiu = chassisSeriesTextBox.Text; autoToModify.ClientId = clientChoosed.ClientId; clonnedSessionData.autoRepository.UpdateAuto(autoToModify); } if (clonnedSessionData.Operation_Type == OperationTypes.ADD_AUTO) { if (string.IsNullOrEmpty(registrationNumberTextBox.Text) || string.IsNullOrEmpty(chassisSeriesTextBox.Text) || clientChoosed == null || chassisSelected == null) { MessageBox.Show("Not all mandatory fields are filled"); return; } Automobil autoToAdd = new Automobil { NumarAuto = registrationNumberTextBox.Text, SerieSasiu = chassisSeriesTextBox.Text, ClientId = clientChoosed.ClientId, SasiuId = chassisSelected.SasiuId }; clonnedSessionData.autoRepository.AddAuto(autoToAdd); } }
public AutoPopupForm(SessionData sessionData) { InitializeComponent(); clonnedSessionData = sessionData; if (clonnedSessionData.Operation_Type == OperationTypes.MODIFY_AUTO || clonnedSessionData.Operation_Type == OperationTypes.ADD_AUTO) { foreach (var client in sessionData.clientRepository.GetClients()) { if (client.ClientId == clonnedSessionData.selectedClient.ClientId) { selectedOwnerIndex = sessionData.clientRepository.GetClients().IndexOf(client); } autoOwnersComboBox.Items.Add(ClientMapper.fromEntityToModel(client)); } foreach (var chassis in sessionData.chassisRepository.GetAllChassis()) { chassisComboBox.Items.Add(ChassisMapper.FromEntityToModel(chassis)); } //chassisComboBox.SelectedItem = ChassisMapper.FromEntityToModel(clonnedSessionData.chassisRepository.GetChassis(chassisId)).ToString(); } }
public HttpResponseMessage GetClientByGuid(Guid guid) { var result = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Client code does not have an active account"); var clientEntity = _lookupService.GetClientByGuid(guid); if (clientEntity == null) { _log.Error(string.Format("Failed to lookup Client by GUID: {0}", guid)); } else { var client = ClientMapper.ToDataTransferObject(clientEntity); var locations = _lookupService.GetLocationsByClientId(clientEntity.Id); if (locations != null && locations.Count() > 0) { client.Locations = locations.Select(x => LocationMapper.ToDataTransferObject(x)).ToList(); } result = Request.CreateResponse(HttpStatusCode.OK, client); } result.Headers.Add("Access-Control-Allow-Origin", "*"); return(result); }