private void ManagerOrdersForm_Load(object sender, EventArgs e)
 {
     using (var ctx = new FactoryContext())
     {
         orderBindingSource.DataSource = ctx.Orders.Where(o => o.Stage == "новый").ToList();
     }
 }
Пример #2
0
 private void RegisterButton_Click(object sender, EventArgs e)
 {
     if (passwordEdit.Text != confirmEdit.Text)
     {
         MessageBox.Show("Ошибка при повторном вводе пароля");
         return;
     }
     else if (!CheckPassword(passwordEdit.Text))
     {
         MessageBox.Show("Пароль должен...");
         return;
     }
     using (var context = new FactoryContext())
     {
         try
         {
             var user = new User
             {
                 Login    = loginEdit.Text,
                 Password = passwordEdit.Text,
                 RoleId   = (int)User.UserRole.Customer,
                 Name     = nameEdit.Text
             };
             context.Users.Add(user);
             context.SaveChanges();
             MessageBox.Show("Вы успешно зарегистрированы и можете войти в систему");
             Back();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
 private void MaterialsForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         materialBindingSource.DataSource = context.Materials.ToList();
     }
 }
Пример #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (var context = new FactoryContext())
            {
                var query = context.Users.Where(u => u.Login == textBox1.Text && u.Password == textBox2.Text);
                if (query.Count() == 0)
                {
                    System.Windows.Forms.MessageBox.Show("Ошибочно введён логин или пароль");
                }
                else
                {
                    switch (query.First().Role)
                    {
                    case User.UserRole.Customer:
                        new CustomerForm(this, query.First()).Open();
                        break;

                    case User.UserRole.Manager:
                        new ManagerForm(this, query.First()).Open();
                        break;

                    case User.UserRole.StoreKeeper:
                        new StoreKeeperForm(this, query.First()).Open();
                        break;

                    case User.UserRole.Director:
                        new DirectorForm(this, query.First()).Open();
                        break;

                    default:
                        break;
                    }
                }
            }
        }
 private void dataGridView1_CellValidated(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 0 && e.RowIndex > -1)
     {
         var row = dataGridView1.Rows[e.RowIndex];
         if (row.Cells[0].Value == null)
         {
             return;
         }
         var id = row.Cells[0].Value.ToString();
         if (id == null)
         {
             return;
         }
         using (var context = new FactoryContext())
         {
             var prod = context.Products.Single(p => p.ProductId == id);
             if (prod.Image == null)
             {
                 return;
             }
             MemoryStream s = new MemoryStream(prod.Image);
             row.Cells[1].Value = System.Drawing.Image.FromStream(s);
         }
     }
 }
Пример #6
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposing)
     {
         FactoryContext.Dispose();
     }
 }
 private void HandledOrdersForm_Load(object sender, EventArgs e)
 {
     using (var ctx = new FactoryContext())
     {
         orderBindingSource.DataSource = ctx.Orders.Where(o => o.ManagerLogin == user.Login && o.ManagerPassword == user.Password).ToList();
     }
 }
 private void FurnituresForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         furnitureBindingSource.DataSource = context.Furnitures.ToList();
     }
 }
        public void Test_AsyncSender_SendSuccess()
        {
            ManualResetEventSlim senderCalledWaiter = new ManualResetEventSlim(initialState: false);

            bool sendCalled = false;

            Task AsyncSenderSend(SharedBuffer buffer, BackgroundErrorCallback raiseBackgroundError)
            {
                sendCalled = true;
                senderCalledWaiter.Set();

                return(Task.CompletedTask);
            }

            FactoryContext factoryContext = CreateFactoryContext(asyncSendFunc: AsyncSenderSend);

            LiveModel liveModel = CreateLiveModel(factoryContext);

            liveModel.Init();
            RankingResponse response = liveModel.ChooseRank(EventId, ContextJsonWithPdf);

            senderCalledWaiter.Wait(TimeSpan.FromSeconds(1));

            Assert.IsTrue(sendCalled);
        }
        private FactoryContext CreateFactoryContext(SenderFactory customFactory)
        {
            FactoryContext factoryContext = new FactoryContext();

            factoryContext.SetSenderFactory(customFactory);

            return(factoryContext);
        }
 private void FurnitureSupplyForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         context.Furnitures.Load();
         furnitureBindingSource.DataSource = context.Furnitures.Local.ToBindingList();
     }
 }
Пример #12
0
 private void MaterialSupplyForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         context.Materials.Load();
         materialBindingSource.DataSource = context.Materials.Local.ToBindingList();
     }
 }
 private void CreateOrderForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         context.Products.Load();
         productBindingSource.DataSource = context.Products.Local.ToBindingList();
     }
 }
Пример #14
0
 static void Main(string[] args)
 {
     using (var dbModel = new FactoryContext())
     {
         dbModel.ManufacturerSet.Add(new Manufacturer {
             Name = "Toyota"
         });
         dbModel.SaveChanges();
     }
 }
 private void ProductsConstructorForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         context.Materials.Load();
         materialBindingSource.DataSource = context.Materials.Local.ToBindingList();
     }
     comboBox1.SelectedIndex = 1;
     pictureBox2_Resize(sender, e);
 }
Пример #16
0
 private void AuthForm_Load(object sender, EventArgs e)
 {
     //Debug code
     using (var context = new FactoryContext())
     {
         var user = context.Users.Where(u => u.RoleId == (int)User.UserRole.StoreKeeper).First();
         textBox1.Text = user.Login;
         textBox2.Text = user.Password;
     }
 }
Пример #17
0
        public async void TasksByNonExistingDevice()
        {
            var fdId = 2222;

            using (var context = new FactoryContext(builder.Options)) {
                IMaintenanceTaskService maintenanceTaskService = new MaintenanceTaskService(context);
                PaginationOpts          paginationOpts         = new PaginationOpts();
                var mts = (await maintenanceTaskService.GetAllByDeviceId(fdId, paginationOpts)).ToList();
                Assert.Empty(mts);
            }
        }
Пример #18
0
 public async void AllTasks()
 {
     using (var context = new FactoryContext(builder.Options)) {
         IMaintenanceTaskService maintenanceTaskService = new MaintenanceTaskService(context);
         PaginationOpts          paginationOpts         = new PaginationOpts();
         var mts = (await maintenanceTaskService.GetAll(paginationOpts)).ToList();
         Assert.NotNull(mts);
         Assert.NotEmpty(mts);
         Assert.Equal(50, mts.Count);
     }
 }
Пример #19
0
        public async void NonExistingTaskWId()
        {
            var mtId = 2222222;

            using (var context = new FactoryContext(builder.Options)) {
                IMaintenanceTaskService maintenanceTaskService = new MaintenanceTaskService(context);
                PaginationOpts          paginationOpts         = new PaginationOpts();
                var mt = (await maintenanceTaskService.Get(mtId));
                Assert.Null(mt);
            }
        }
Пример #20
0
 public async void AllDevices()
 {
     using (var context = new FactoryContext(builder.Options)) {
         IFactoryDeviceService factoryDeviceService = new FactoryDeviceService(context);
         PaginationOpts        paginationOpts       = new PaginationOpts();
         var fds = (await factoryDeviceService.GetAll(paginationOpts)).ToList();
         Assert.NotNull(fds);
         Assert.NotEmpty(fds);
         Assert.Equal(50, fds.Count);
     }
 }
Пример #21
0
        public async void NonExistingDeviceWithId()
        {
            int fdId = 2222;

            using (var context = new FactoryContext(builder.Options)) {
                IFactoryDeviceService factoryDeviceService = new FactoryDeviceService(context);
                PaginationOpts        paginationOpts       = new PaginationOpts();
                var fd = (await factoryDeviceService.Get(fdId));
                Assert.Null(fd);
            }
        }
        public override object Create(IEnumerable <string> mediaTypes, FactoryContext context)
        {
            McuSession mcuSession = null;

            if (mediaTypes.Contains <string>(MediaType.ApplicationSharing))
            {
                mcuSession = new ApplicationSharingMcuSession();
            }

            return(mcuSession);
        }
        /// <summary>
        /// Creates a processor instance to handle the mcu type and media types specified.
        /// </summary>
        /// <param name="mediaTypes">The media type for which to create the McuNotificationProcessor</param>
        /// <param name="context">The context for creating the object.</param>
        /// <returns>
        /// A processor that can handle notifications for the given mcu category.
        /// Returns null if a processor is not available to handle the category.
        /// </returns>
        public override object Create(IEnumerable <string> mediaTypes, FactoryContext context)
        {
            ConferenceMcuNotificationProcessor mcuNotificationProcessor = null;

            if (mediaTypes.Contains <string>(MediaType.ApplicationSharing))
            {
                mcuNotificationProcessor = new ApplicationSharingMcuSessionNotificationProcessor(context.Conversation.ConferenceSession);
            }

            return(mcuNotificationProcessor);
        }
Пример #24
0
    public void Throws_for_constructor_with_properties()
    {
        using var context = new FactoryContext();

        var entityType = context.Model.FindEntityType(typeof(WithProperties));

        Assert.Equal(
            CoreStrings.NoParameterlessConstructor(nameof(WithProperties)),
            Assert.Throws <InvalidOperationException>(
                () => entityType.GetInstanceFactory()).Message);
    }
Пример #25
0
        public void Initialize(FactoryContext factoryContext, Building building)
        {
            this.Id    = building.Id;
            this.Title = building.Title;

            foreach (var room in building.Children)
            {
                var roomModel = new RoomModel();
                roomModel.Initialize(factoryContext, room);
                this.Rooms.Add(roomModel);
            }
        }
Пример #26
0
 public void AddDeliverer(DelivererModel delivererModel)
 {
     if (delivererModel != null)
     {
         using (FactoryContext context = new FactoryContext())
         {
             Deliverer deliverer = new Deliverer();
             deliverer.DelivererName = delivererModel.DelivererName;
             context.Deliverers.Add(deliverer);
             context.SaveChanges();
         }
     }
 }
Пример #27
0
    public void Create_instance_with_parameterless_and_with_properties()
    {
        using var context = new FactoryContext();

        var entityType = context.Model.FindEntityType(typeof(ParameterlessAndWithProperties));
        var factory    = entityType.GetInstanceFactory();
        var instance1  = factory(new MaterializationContext(ValueBuffer.Empty, context));
        var instance2  = factory(new MaterializationContext(ValueBuffer.Empty, context));

        Assert.IsType <ParameterlessAndWithProperties>(instance1);
        Assert.IsType <ParameterlessAndWithProperties>(instance2);
        Assert.NotSame(instance1, instance2);
    }
Пример #28
0
        /// <summary>
        /// Overrides the default creation to create an ApplicationSharingCall
        /// </summary>
        public override object Create(IEnumerable <string> mediaTypes, FactoryContext context)
        {
            Conversation conversation = context.Conversation;

            Call call = null;

            if (mediaTypes.Contains <string>(MediaType.ApplicationSharing))
            {
                call = new ApplicationSharingCall(conversation);
            }

            return(call);
        }
Пример #29
0
 private void ProducedProductsForm_Load(object sender, EventArgs e)
 {
     using (var context = new FactoryContext())
     {
         var query = context.PruducedProducts.AsEnumerable().Select(prod => new
         {
             prod.ProductId,
             prod.Product.Name,
             prod.Quantity,
             prod.Product.Price
         });
         dataGridView1.DataSource = query.ToList();
     }
 }
        private LiveModel CreateLiveModel(FactoryContext factoryContext = null)
        {
            Configuration config;
            ApiStatus     apiStatus = new ApiStatus();

            if (!Configuration.TryLoadConfigurationFromJson(CustomSenderConfigJson, out config, apiStatus))
            {
                Assert.Fail("Failed to parse pseudolocalized configuration JSON: " + apiStatus.ErrorMessage);
            }

            LiveModel liveModel = factoryContext == null ? new LiveModel(config) : new LiveModel(config, factoryContext);

            return(liveModel);
        }