private ViewModels.ProductViewModel StageProduct(ProductData data, string group, string connectionId) { ViewModels.ProductViewModel resVm = new ViewModels.ProductViewModel(); int dangerIdx = 0; if (string.IsNullOrEmpty(group)) { resVm.ErrorMessage = "stageProduct - no groupname given...."; resVm.ErrorNumber = 7710; return(resVm); } if (Utils.ValidationUtils.IsDangerousString(group, out dangerIdx)) { resVm.ErrorMessage = "invalid groupname given...."; resVm.ErrorNumber = 7710; return(resVm); } List <string> vmessages = new List <string>(); if (Utils.ProductUtils.IsValidProductData(data, out vmessages)) { var newProduct = productRepository.ProductAddOrUpdate(new ViewModels.ProductViewModel() { Name = data.Name, Description = data.Description, Owner = userRepository.GetUserFromSignalR(connectionId), Price = data.Price, PartNumber = data.PartNumber }); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Group(group).productStaged(newProduct.ToProductViewModel()); resVm.Identifier = newProduct.ProductIdentifier; resVm.Name = newProduct.Name; resVm.Owner = newProduct.Owner.ToUserDataViewModel(); resVm.Price = newProduct.Price; } resVm.ErrorMessage = vmessages.FirstOrDefault();; return(resVm); }
// [Authorize] public List <ViewModels.OrderViewModel> getOrders(Enums.EnumGuiType guiType, string group, FilterSortConfig config) { var dbService = db.ServiceSettings.FirstOrDefault(ln => ln.ServiceUrl == group); if (dbService == null) { return(new List <ViewModels.OrderViewModel>()); } var user = userRepository.GetUserFromSignalR(Context.ConnectionId); var allorders = orderRepository.GetOrders(user.Id, guiType); var sortedorders = Utils.OrderUtils.SortByConfig(allorders, config.Sorters); return(sortedorders); }