public HttpResponseMessage GetOperations(HttpRequestMessage request, string email) { try { var resourcesToBuy = GetResources(); var resourcesToSell = _userResourcesService.GetUserResources(email); var profits = _dealService.GetProfits(email); var operationViewModel = new OperationsViewModel { ResourcesToBuy = resourcesToBuy, ResourcesToSell = resourcesToSell, Profit = profits, Balance = resourcesToSell.First().User.Balance }; return(request.CreateResponse(HttpStatusCode.OK, new { success = true, operations = operationViewModel })); } catch (Exception e) { _logger.Error(e); return(request.CreateResponse(HttpStatusCode.OK, new { success = false, message = Messages.CantLoadResources })); } }
public async Task <IActionResult> UpdateOperation(int id, OperationsViewModel oper) { if (id != oper.OperationId) { return(BadRequest()); } await _operService.UpdateOper(oper); return(Ok()); }
public MainWindowViewModel( IFilesOperationsMediator filesOperationsMediator, OperationsViewModel operationsViewModel, FilesPanelViewModel leftFilesPanelViewModel, FilesPanelViewModel rightFilesPanelViewModel, MenuViewModel menuViewModel) { OperationsViewModel = operationsViewModel; LeftFilesPanelViewModel = leftFilesPanelViewModel; RightFilesPanelViewModel = rightFilesPanelViewModel; MenuViewModel = menuViewModel; // TODO: from settings filesOperationsMediator.Register(leftFilesPanelViewModel, rightFilesPanelViewModel); }
public async Task <IActionResult> SearchOperations(string key, int type) { var nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone(); nfi.NumberGroupSeparator = " "; string lowerKey = null; if (key != null) { lowerKey = key.ToLower(); } var model = new OperationsViewModel { Items = (from info in _db.VBookingManagementOperations where (type == 1 && info.TicketID.ToLower().Contains(lowerKey)) || (type == 2 && info.FullName.ToLower().Contains(lowerKey)) || (type == 3 && info.PNRID.ToLower().Contains(lowerKey)) || (type == 4 && info.Passport.ToLower().Contains(lowerKey)) orderby info.ExecutionDateTime select new OperationsViewItem { TicketNumber = info.TicketID, Airline = info.Airline, Route = info.Flight, DepartureDateTime = info.FlightDate.ToString("g"), OperationType = info.OperationType, TicketCost = (info.Fare + info.TaxAmount).ToString("#,0.00", nfi), ServiceTax = info.KRSTax, Penalty = info.Penalty.ToString("#,0.00", nfi), PassengerName = info.FullName, Phone = info.Phone, Email = info.Email, Desk = info.DeskID, OperationDateTime = info.ExecutionDateTime.ToString("g"), BookDesk = info.BookDeskID, BookDateTime = info.BookDateTime == null ? "" : info.BookDateTime.Value.ToString("g"), PaymentType = info.PaymentType, BirthDate = info.BirthDate == null ? "" : info.BirthDate.Value.ToString("d"), Passport = info.Passport }).ToList() }; return(Json(new { message = await _viewRenderService.RenderToStringAsync("BookingManagement/Operations", model) })); }
public async Task <ActionResult> CreateOperation(OperationsViewModel model) { if (model.Message == "") { if (model.Concept == "Salida") { model.Message = "Retirada de dinero"; } else { model.Message = "Entrada de dinero"; } } var result = await _operService.CreateOperation(model); return(result); }
public OperationsViewModel GetMyOperations(DataSourceRequest request) { var model = new OperationsViewModel(); //get current user id var current_user = IDBContext.Current.UserName; //get list of operations in wich the current user have access var user_operations = sharepoint_repository .GetUserOperations(current_user); var operation_parameter = string.Join(",", user_operations.ToArray()); //get current user operations GlobalsRepository.GetOperations(operation_parameter, request); return(model); }
internal async Task <ActionResult> CreateOperation(OperationsViewModel model) { var result = _context.Operations.Add(model); await _context.SaveChangesAsync(); account = await _accountService.findAccountToUpdateById(model.AccountId); if (model.Concept.Equals("Entrada")) { account.Balance += model.Amount; } else { account.Balance -= model.Amount; } await _accountService.updateAccount(account); return(Ok()); }
private static void Configure( ComponentLocation componentLocation, ApplicationBootstrap bootstrap, ApplicationContext applicationContext, BackgroundTasks backgroundTasks) { var operationsOutputViewModel = new OperationsOutputViewModel(); var operationPropertiesViewModel = new OperationPropertiesViewModel(); var scriptOperationsViewModel = new ScriptOperationsViewModel(operationPropertiesViewModel); var operationsViewModel = new OperationsViewModel(operationPropertiesViewModel); var operationViewsViewModel = new OperationViewsViewModel(new OperationsViewInitialization[] { operationsViewModel, scriptOperationsViewModel }); var componentInstancesViewModel = new ComponentInstancesViewModel(operationsViewModel, operationViewsViewModel); var operationMachinesByControlObject = new OperationMachinesByControlObject(); var outputFactory = new OutputFactory(operationsOutputViewModel); var testComponentViewModelFactory = new TestComponentViewModelFactory( componentInstancesViewModel, outputFactory, new WpfOperationViewModelFactory(applicationContext, scriptOperationsViewModel, new PropertySetBuilderFactory()), backgroundTasks, operationMachinesByControlObject, bootstrap); var componentsViewModel = new ComponentsViewModel(testComponentViewModelFactory); var topMenuBarViewModel = new TopMenuBarViewModel( componentInstancesViewModel, operationsOutputViewModel, new PersistentModelContentBuilderFactory(operationsOutputViewModel, operationMachinesByControlObject)); var factoryRepositories = componentLocation.LoadComponentRoots(); AddAllInstanceFactories(factoryRepositories, componentsViewModel); bootstrap.SetOperationPropertiesViewDataContext(operationPropertiesViewModel); bootstrap.SetTopMenuBarContext(topMenuBarViewModel); bootstrap.SetOperationsViewDataContext(operationsViewModel); bootstrap.SetScriptOperationsViewDataContext(scriptOperationsViewModel); bootstrap.SetOperationsOutputViewDataContext(operationsOutputViewModel); bootstrap.SetComponentsViewDataContext(componentsViewModel); bootstrap.SetComponentInstancesViewDataContext(componentInstancesViewModel); bootstrap.SetOperationsViewsViewDataContext(operationViewsViewModel); return; }
public ActionResult Index() { var viewModel = new OperationsViewModel { Filter = new OperationsFilter { Responsibles = new List <int> { CurrentUserId }, PageSize = 50 } }; viewModel.Items = orderLogic.GetOperations(viewModel.Filter).ToList(); viewModel.Dictionaries.Add("OperationStatus", dataLogic.GetOperationStatuses()); viewModel.Dictionaries.Add("OrderOperation", dataLogic.GetOrderOperations()); viewModel.Dictionaries.Add("OperationKind", dataLogic.GetOperationKinds()); viewModel.Dictionaries.Add("ActiveUser", dataLogic.GetActiveUsers()); viewModel.Dictionaries.Add("Order", dataLogic.GetOrders()); viewModel.Dictionaries.Add("User", dataLogic.GetUsers()); return(View(viewModel)); }
public virtual ActionResult Index() { var authorizationManagerClient = Globals.Resolve <IAuthorizationManager>(); var roles = authorizationManagerClient.GetRoles(IDBContext.Current.UserLoginName, string.Empty); var userIsGlobal = _operationService.IsRoleTypeGlobal(roles); var commonLogin = new GlobalCommonLogic(); var model = new OperationsViewModel(); ViewBag.TotalOperations = 0; ViewBag.OpDetailURL = Url.Action("Operation", "Mainframe"); //GlobalCommonLogic.GetOperationDetailURL(); model.LastViewed = commonLogin.GetOperationsLastViewed(); if (userIsGlobal) { model.IsGlobal = true; return(View(model)); } model.IsGlobal = false; return(View(model)); }
public async Task <IActionResult> Operations(DateTime?fromDate, DateTime?toDate, string[] deskFilter, string[] sessionFilter, string[] airlineFilter) { var nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone(); nfi.NumberGroupSeparator = " "; var queryToDate = toDate ?? DateTime.Now.Date; var queryFromDate = fromDate ?? queryToDate; var model = new OperationsViewModel { Items = (from info in _db.VBookingManagementOperations where info.ExecutionDateTime >= queryFromDate && info.ExecutionDateTime < queryToDate.AddDays(1) && deskFilter.Contains(info.DeskID) && sessionFilter.Contains(info.Session) orderby info.ExecutionDateTime select new OperationsViewItem { TicketNumber = info.TicketID, Airline = info.Airline, Route = info.Flight, DepartureDateTime = info.FlightDate.ToString("g"), OperationType = info.OperationType, TicketCost = (info.Fare + info.TaxAmount).ToString("#,0.00", nfi), ServiceTax = info.KRSTax, Penalty = info.Penalty.ToString("#,0.00", nfi), PassengerName = info.FullName, Phone = info.Phone, Email = info.Email, Desk = info.DeskID, OperationDateTime = info.ExecutionDateTime.ToString("g"), BookDesk = info.BookDeskID, BookDateTime = info.BookDateTime == null ? "" : info.BookDateTime.Value.ToString("g"), PaymentType = info.PaymentType, AtolServerName = info.AtolServerName }).ToList() }; return(Json(new { message = await _viewRenderService.RenderToStringAsync("BookingManagement/Operations", model) })); }
public OperationsPage() { InitializeComponent(); BindingContext = viewModel = new OperationsViewModel(); }
public async Task <ActionResult> UpdateOper(OperationsViewModel oper) { var result = await _operRepository.UpdateOper(oper); return(result); }
public ActionResult Operations(int?manager, int?client, int?product, int?lowCost, int?highCost, DateTime?date) { bool auth = AuthenticationManager.User.IsInRole("admin"); try { IEnumerable <OperationDTO> operationDTOs = operationService.GetOperations(); if (manager != null && manager != 0) { operationDTOs = operationDTOs.Where(p => p.ManagerId == manager); } if (client != null && client != 0) { operationDTOs = operationDTOs.Where(p => p.ClientId == client); } if (product != null && product != 0) { operationDTOs = operationDTOs.Where(p => p.ProductId == product); } if (lowCost != null && highCost != null && highCost != 0) { operationDTOs = operationDTOs.Where(p => p.Cost >= lowCost && p.Cost <= highCost); } if (date != null) { operationDTOs = operationDTOs.Where(p => p.Date == date); } if (operationDTOs.Count() == 0) { ViewBag.Message = ViewBag.Message + "Operations not found"; } Mapper.Initialize(cfg => cfg.CreateMap <OperationDTO, OperationViewModel>()); IEnumerable <OperationViewModel> operations = Mapper.Map <IEnumerable <OperationDTO>, List <OperationViewModel> >(operationDTOs); List <ManagerDTO> managerDTOs = operationService.GetManagers().ToList(); managerDTOs.Insert(0, new ManagerDTO { Nickname = "All", Id = 0 }); List <ClientDTO> clientDTOs = operationService.GetClients().ToList(); clientDTOs.Insert(0, new ClientDTO { Nickname = "All", Id = 0 }); List <ProductDTO> productDTOs = operationService.GetProducts().ToList(); productDTOs.Insert(0, new ProductDTO { Name = "All", Id = 0 }); OperationsViewModel opv = new OperationsViewModel { Managers = new SelectList(managerDTOs, "Id", "Nickname"), Clients = new SelectList(clientDTOs, "Id", "Nickname"), Products = new SelectList(productDTOs, "Id", "Name"), SomeOperations = operations.ToList() }; ViewBag.IsAdmin = auth; return(View(opv)); } catch (Exception e) { if (auth) { ViewBag.ErrorInformation(e.ToString()); return(View("Error")); } else { return(HttpNotFound()); } } }
internal async Task <ActionResult> UpdateOper(OperationsViewModel oper) { var elderElement = await _context.Operations.FindAsync(oper.OperationId); var conceptElder = elderElement.Concept; var amountElder = elderElement.Amount; try { if (elderElement.AccountId != oper.AccountId) { elderElement.AccountId = oper.AccountId; } if (elderElement.Amount != oper.Amount) { elderElement.Amount = oper.Amount; } if (elderElement.Concept != oper.Concept) { elderElement.Concept = oper.Concept; } if (elderElement.Date != oper.Date) { elderElement.Date = oper.Date; } if (elderElement.Message != oper.Message) { elderElement.Message = oper.Message; } //this is the same but it gives an error when 2 elements with the same id are being tracked //_context.Entry(oper).State = EntityState.Modified; } catch (Exception e) { Console.Write(e.Message); } await _context.SaveChangesAsync(); account = await _accountService.findAccountToUpdateById(oper.AccountId); if (oper.Concept == "Entrada" && conceptElder == "Entrada") { if (amountElder > oper.Amount) { account.Balance -= (amountElder - oper.Amount); } else { account.Balance += (oper.Amount - amountElder); } } else if (oper.Concept == "Salida" && conceptElder == "Salida") { if (amountElder > oper.Amount) { account.Balance += (amountElder - oper.Amount); } else { account.Balance -= (oper.Amount - amountElder); } } else if (oper.Concept == "Salida" && conceptElder == "Entrada") { account.Balance -= (amountElder + oper.Amount); } else { account.Balance += (amountElder + oper.Amount); } await _accountService.updateAccount(account); return(Ok()); }
public async Task <ActionResult> CreateOperation(OperationsViewModel model) { return(await _operRepository.CreateOperation(model)); }
void ApplicationBootstrap.SetOperationsViewDataContext(object operationsViewModel) { _operationsViewModel = (OperationsViewModel)operationsViewModel; }
public async Task <ActionResult> DeleteOper(OperationsViewModel oper) { return(await _operRepository.DeleteOper(oper)); }
public OperationsPage(OperationsViewModel operationsViewModel) : this() { BindingContext = operationsViewModel; }
public FakeOperationsView(OperationsViewModel operationsViewModel) { _operationsViewModel = operationsViewModel; }