private void setServiceCreatorButton_Click(object sender, EventArgs e) { serviceCreator = (ServiceCreator)Activator.GetObject( typeof(ServiceCreator), ServiceCreatorTextBox.Text ); }
public ActionResult EditCatList(Guid menuId, List <string> sortedCat) { try { var service = ServiceCreator.GetManagerService(User.Identity.Name); var categories = new List <string>(); foreach (var cat in sortedCat) { if (cat == "") { categories.Add(null); } else { categories.Add(cat); } } service.UpdateMenuCategories(menuId, categories); return(Json(new { isAuthorized = true, isSuccess = true })); } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
public ActionResult AllMenus() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var menus = service.GetAllMenus(); var model = Mapper.Map <List <MenuViewModel> >(menus); model.ForEach(o => { var rest = service.GetRestaurantByMenu(o.Id); if (rest != null) { o.AttachedRestaurantName = rest.Name; } if (o.DishList != null && o.DishList.Any()) { var groupedDishes = o.DishList.GroupBy(d => d.Category).Select(d => new DishListViewModel { Category = d.Key, Dishes = Mapper.Map <List <DishViewModel> >(d.ToList()) }).ToList(); o.GroupedDishes = new List <DishListViewModel>(); foreach (var category in o.CategoriesSorted) { o.GroupedDishes.AddRange(groupedDishes.Where(g => g.Category == category)); } } else { o.GroupedDishes = new List <DishListViewModel>(); } }); return(View("MenuCardList", model)); }
public ActionResult AllModificators() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var mods = Mapper.Map <List <ModificatorViewModel> >(service.GetAllModificators()); return(View("ModificatorCardList", mods)); }
public StatController() { if (serviceCreator == null) { serviceCreator = new ServiceCreator(); } }
public SchoolClassesController() { if (serviceCreator == null) { serviceCreator = new ServiceCreator(); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(optitons => optitons.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = JwtOptions.ISSUER, ValidateAudience = true, ValidAudience = JwtOptions.AUDIENCE, ValidateLifetime = true, IssuerSigningKey = JwtOptions.GetSymmetricSecurityKey(), ValidateIssuerSigningKey = true }; }); ServiceCreator serviceCreator = new ServiceCreator(Configuration.GetConnectionString("DefaultConnection")); services.AddScoped <ICommentService, CommentService>(conf => serviceCreator.CreateCommentService()); services.AddScoped <IPostService, PostService>(conf => serviceCreator.CreatePostService()); services.AddScoped <IUserProfileService, UserProfileService>(conf => serviceCreator.CreateUserProfileService()); services.AddScoped <IApplicationUserService, ApplicationUserService>(conf => serviceCreator.CreateApplicationUserService()); }
public ActionResult TableSetProccesed(Guid tableId, bool value) { try { var service = ServiceCreator.GetManagerService(User.Identity.Name); var config = new RegistrationService().FindConfiguration(User.Identity.Name); var table = service.GetTable(tableId); if (table != null) { table.OrderProcessed = value; service.UpdateTable(table); //if (value) //{ // new BotClient(config.TelegramBotLocation).SendNotification(table.ChatId, "Ваш заказ принят!"); //} } else { throw new ArgumentNullException("Table not found!"); } return(Json(new { isAuthorized = true, isSuccess = true })); } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
public ValuesController() { if (serviceCreator == null) { serviceCreator = new ServiceCreator(); } }
public ActionResult AllDispatches() { var regService = ServiceCreator.GetRegistrationService(); var account = regService.FindAccount(User.Identity.Name); if (account != null) { var service = ServiceCreator.GetDispatchesService(); var activeDispatches = service.GetActiveDispatches(account.Id); var oldDispatches = service.GetInActiveDispatches(account.Id); var model = new DispatchListViewModel(); model.ActiveDispatches = Mapper.Map <List <DispatchViewModel> >(activeDispatches); model.InActiveDispatches = Mapper.Map <List <DispatchViewModel> >(oldDispatches); return(View("DispatchCardList", model)); } else { var model = new DispatchListViewModel(); model.ActiveDispatches = new List <DispatchViewModel>(); model.InActiveDispatches = new List <DispatchViewModel>(); return(View("DispatchCardList", model)); } }
public ActionResult AllTables() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var activeTables = new List <Table>(); var inActiveTables = new List <Table>(); var restCookie = Request.Cookies.Get("CurRest"); if (restCookie != null) { var curRest = Guid.Parse(restCookie.Value); if (curRest != Guid.Empty) { activeTables = service.GetManagerTables(curRest).OrderByDescending(o => o.OrderPlaced).ToList(); inActiveTables = service.GetInActiveTables(curRest).OrderByDescending(o => o.OrderPlaced).Take(20).ToList(); } else { activeTables = service.GetManagerTables().OrderByDescending(o => o.OrderPlaced).ToList(); inActiveTables = service.GetInActiveTables().OrderByDescending(o => o.OrderPlaced).Take(20).ToList(); } } else { activeTables = service.GetManagerTables().OrderByDescending(o => o.OrderPlaced).ToList(); inActiveTables = service.GetInActiveTables().OrderByDescending(o => o.OrderPlaced).Take(20).ToList(); } var model = new AllTablesViewModel { ActiveTables = Mapper.Map <List <TableCardViewModel> >(activeTables), InActiveTables = Mapper.Map <List <TableCardViewModel> >(inActiveTables) }; return(View("TableCardList", model)); }
public ActionResult EditMods(Guid dishId, List <int> allActiveMods) { try { var service = ServiceCreator.GetManagerService(User.Identity.Name); var curDish = service.GetDish(dishId); var allMods = service.GetAllModificators(); if (curDish != null && allMods != null) { if (allActiveMods != null) { var modsForCurDish = allMods.Where(o => allActiveMods.Contains(o.Id)).Select(o => o.Id).ToList(); curDish.ModIds = modsForCurDish; } else { curDish.ModIds = new List <int>(); } service.UpdateDish(curDish); } else { throw new ArgumentNullException("Dish or list of dishes not found!"); } return(Json(new { isAuthorized = true, isSuccess = true })); } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
public ActionResult EditDish(Guid dishId) { try { var service = ServiceCreator.GetManagerService(User.Identity.Name); var dish = service.GetDish(dishId); if (dish != null) { var model = Mapper.Map <DishViewModel>(dish); var allDishes = service.GetAllDishes(); if (allDishes != null && allDishes.Any()) { model.AvailableCategories = allDishes.Where(o => !string.IsNullOrEmpty(o.Category)).Select(o => o.Category).Distinct().ToList(); } return(View("DishCardEdditable", model)); } else { throw new Exception("Dish not found!"); } } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
public TeacherController() { if (serviceCreator == null) { serviceCreator = new ServiceCreator(); } }
public JsonResult EditMenuDishes(Guid menuId, List <Guid> allActiveDishes) { try { var service = ServiceCreator.GetManagerService(User.Identity.Name); var curMenu = service.GetMenu(menuId); var allDishes = service.GetAllDishes(); if (curMenu != null && allDishes != null) { if (allActiveDishes != null) { var dishesForCurmenu = allActiveDishes.Select(o => allDishes.Where(a => a.Id == o).FirstOrDefault()).ToList(); //var dishesForCurmenu = allDishes.Where(o => allActiveDishes.Contains(o.Id)).ToList(); curMenu.DishList = dishesForCurmenu; } else { curMenu.DishList = new List <Dish>(); } service.UpdateMenu(curMenu); } else { throw new ArgumentNullException("Menu or list of dishes not found!"); } return(Json(new { isAuthorized = true, isSuccess = true })); } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
public ActionResult EditDish(Dish dish) { try { if (string.IsNullOrEmpty(dish.ShortName)) { dish.ShortName = dish.Name; } var service = ServiceCreator.GetManagerService(User.Identity.Name); if (dish.Id == Guid.Empty) { service.CreateNewDish(dish); } else { service.UpdateDish(dish); } return(Json(new { isAuthorized = true, isSuccess = true })); } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
private void buttonExecuteScript_Click(object sender, EventArgs e) { List <Command> commands = new List <Command>(); try { commands = new ScriptParser().parseFile(script.Text); } catch (System.IO.FileNotFoundException err) { MessageBox.Show(err.Message); return; } foreach (Command cmd in commands) { logs.Text += ("Exec: " + cmd.CommandName + " | " + cmd.getArgsAsString() + "\n"); var args = cmd.Args; switch (cmd.CommandName) { case "Client": instantiateClient(args[0], args[1], args[2], args[3]); break; case "Server": instantiateServer(args[0], args[1], args[2], args[3], args[4]); break; case "Wait": System.Threading.Thread.Sleep(Int32.Parse(args[0])); break; case "AddRoom": addRoom(args[0], args[1], args[2]); break; case "Status": showStatus(); break; case "Crash": IServer affectedServer = servers[args[0]]; affectedServer.crash(); appendMessage("Server crashed"); break; case "PSC": serviceCreator = (ServiceCreator)Activator.GetObject( typeof(ServiceCreator), args[0] ); break; default: appendMessage("Command Not Implemented" + cmd.CommandName + "\n"); break; } } }
public void Create_TypeWithDefaultConstructor_ReturnsNewInstance() { var subject = new ServiceCreator(); object result = subject.Create(typeof(StringBuilder), _containerMock.Object); Assert.NotNull(result); Assert.IsInstanceOf <StringBuilder>(result); }
public void Create_ArgumentsCannotBeResolved_ThrowsException() { var subject = new ServiceCreator(); Assert.Throws <InvalidOperationException>(() => { subject.Create(typeof(SetupMatcher), _containerMock.Object); }); }
public ActionResult AllRestaurants() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var rests = service.GetAllRestaurants(); var model = Mapper.Map <List <RestaurantViewModel> >(rests); return(View("RestaurantCardList", model)); }
private void InitServiceCreator(BcatServiceType type, string name, AccessControl accessControl) { lock (_bcatServiceInitLocker) { Debug.Assert((uint)type < ServiceTypeCount); ServiceCreators[(int)type] = new ServiceCreator(this, name, accessControl); } }
public ActionResult AllCheques() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var cheques = service.GetAllCheques().OrderByDescending(o => o.Date); var model = Mapper.Map <List <ChequeViewModel> >(cheques).ToList(); return(View("ChequeCardList", model)); }
public bool Login(string login, string password) { var hash = Encrypt(password); var service = ServiceCreator.GetRegistrationService(); var account = service.FindAccount(login); return(account != null && account.PasswordHash == hash); }
public ActionResult AllFeedbacks() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var feedbacks = service.GetAllFeedbacks().OrderByDescending(o => o.Date); var model = Mapper.Map <List <FeedbackViewModel> >(feedbacks).ToList(); return(View("FeedbackCardList", model)); }
public ActionResult MenuCatList(Guid menuid) { var service = ServiceCreator.GetManagerService(User.Identity.Name); var curMenu = service.GetMenu(menuid); var model = curMenu.CategoriesSorted; return(View(model)); }
private static void UninstallService(string filename) { var serviceName = Path.GetFileNameWithoutExtension(filename); var serviceCreator = new ServiceCreator(filename, serviceName); serviceCreator.RemoveService(); //ManagedInstallerClass.InstallHelper(new string[] { "/u", filename }); }
public void Create_Interface_ThrowsException() { var subject = new ServiceCreator(); Assert.Throws <InvalidOperationException>(() => { subject.Create(typeof(IDisposable), _containerMock.Object); }); }
public ActionResult Add(CardTypes activeSection) { try { var service = ServiceCreator.GetManagerService(User.Identity.Name); switch (activeSection) { case CardTypes.Dish: { var model = new DishViewModel(); var allDishes = service.GetAllDishes(); if (allDishes != null && allDishes.Any()) { model.AvailableCategories = allDishes.Where(o => !string.IsNullOrEmpty(o.Category)).Select(o => o.Category).Distinct().ToList(); } return(View("DishCardEdditable", model)); } case CardTypes.Menu: { var model = new MenuViewModel(); var rests = service.GetAllRestaurants(); if (rests != null && rests.Any()) { model.AvailableRests = Mapper.Map <List <RestaurantDropDown> >(rests); } return(View("MenuCardEdditable", model)); } case CardTypes.Restaurant: { return(View("RestaurantCardEdditable", new RestaurantViewModel())); } case CardTypes.Dispatch: { return(View("DispatchCardEdditable", new DispatchViewModel())); } case CardTypes.Mod: { return(View("ModificatorsCardEdditable", new ModificatorViewModel())); } default: throw new Exception("No active section"); } } catch (Exception ex) { return(Json(new { isAuthorized = true, isSuccess = false, error = ex.Message })); } }
public ActionResult AllDishes() { var service = ServiceCreator.GetManagerService(User.Identity.Name); var dishes = service.GetAllDishes(); var model = dishes.GroupBy(o => o.Category).Select(o => new DishListViewModel { Category = o.Key, Dishes = Mapper.Map <List <DishViewModel> >(o.ToList()) }).ToList(); return(View("DishCardList", model)); }
private static void InstallService(string filename) { var serviceName = Path.GetFileNameWithoutExtension(filename); var serviceCreator = new ServiceCreator(filename, serviceName); serviceCreator.CreateService(); //@"sc.exe create AmagnoClassificationService binPath=%rootPath%AmagnoClassificationService\bin\AmagnoClassificationService.exe start=delayed-auto" //ManagedInstallerClass.InstallHelper(new string[] { filename }); }
public static ServiceCreatorCallback CreateCallback(Type serviceType, Type serviceInstanceType) { if (serviceType == null) throw new ArgumentNullException("serviceType"); if (serviceInstanceType == null) throw new ArgumentNullException("serviceInstanceType"); if (!serviceType.IsAssignableFrom(serviceInstanceType)) { throw new ArgumentException("Type is not compatible", "serviceInstanceType"); } ConstructorInfo[] constructors = serviceInstanceType.GetConstructors(); if (constructors.Length > 1) { string message = String.Format("Too many constructors for {0}", serviceInstanceType); throw new ArgumentException(message); } if (constructors.Length == 0) { string message = String.Format("No public constructor for {0}", serviceInstanceType); throw new ArgumentException(message); } ConstructorInfo constructor = constructors[0]; if (constructor.ContainsGenericParameters) { string message = String.Format("Unassigned generic parameters in type {0}", serviceInstanceType); throw new ArgumentException(message); } foreach (ParameterInfo parameter in constructor.GetParameters()) { if (!parameter.ParameterType.IsInterface) { string message = String.Format("Constructor for {0} has a non-interface parameter: {1}", serviceInstanceType, parameter); throw new ArgumentException(message); } } ServiceCreator factory = new ServiceCreator(constructor); return new ServiceCreatorCallback(factory.ServiceCreatorCallback); }