public void CreateMethodTest()
        {
            var options = new DbContextOptionsBuilder <MContext>()
                          .UseInMemoryDatabase(databaseName: "DB")
                          .Options;
            var controller = new StagesController(new MContext(options));

            using (var context = new MContext(options))
            {
                context.Stages.Add(new Stage());
                context.SaveChanges();
            }

            using (var context = new MContext(options))
            {
                var result = controller.Create(new Stage());
                Assert.AreEqual(true, result.IsCompletedSuccessfully);
            }
        }
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            Start.IsEnabled = false;
            MContext   mc   = new MContext();
            List <SKU> lsku = mc.SKUs.ToList();

            foreach (SKU s in lsku)
            {
                s.AlloPrice     = 0;
                s.AlloPromo     = 0;
                s.ChangePrice   = false;
                s.ComfyPrice    = 0;
                s.ComfyPromo    = 0;
                s.EldoradoPrice = 0;
                s.EldoradoPromo = 0;
                s.HotlinePrice  = 0;
                s.RozetkaPrice  = 0;
                s.RozetkaPromo  = 0;
                s.TotalPrice    = 0;
                s.TotalPromo    = 0;
                mc.SaveChanges();
            }
            List <string> lUrlComfy    = new List <string>();
            List <string> lUrlRozetka  = new List <string>();
            List <string> lUrlAllo     = new List <string>();
            List <string> lUrlEldorado = new List <string>();

            foreach (Subcategory s in CheckSubcategory.SelectedItems)
            {
                lUrlComfy.Add(s.UrlComfy);
                lUrlRozetka.Add(s.UrlRozetka);
                lUrlAllo.Add(s.UrlAllo);
                lUrlEldorado.Add(s.UrlEldorado);
            }
            UrlCompetitors uc = new UrlCompetitors()
            {
                lUrlComfy = lUrlComfy, lUrlRozetka = lUrlRozetka, lUrlAllo = lUrlAllo, lUrlEldorado = lUrlEldorado
            };
            Thread th = new Thread(SeeTread);

            th.Start(uc);
        }
Example #3
0
        public JsonResult GetStudents(string term)
        {
            MContext      s_context = new MContext();
            List <string> students;

            //if (string.IsNullOrEmpty(term))
            //{
            //    students = s_context.DbSetStudents.ToList();
            //}
            //else

            students = s_context
                       .DbSetStudents
                       .Where(x => x.Name.StartsWith(term))
                       .Select(y => y.Name)
                       .ToList();


            return(Json(students, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        // [HttpPost]
        public ActionResult DeleteConfirmed(bool confirm, int id)
        {
            if (confirm)
            {
                MContext s_context = new MContext();

                var stu = s_context.DbSetStudents.Find(id);
                s_context.DbSetStudents.Remove(stu);
                s_context.SaveChanges();

                return(RedirectToAction("Index", "Student"));
                //return true;
                //return new HttpStatusCodeResult(HttpStatusCode.OK);
                //return Json(JsonRequestBehavior.DenyGet);
            }
            else
            {
                return(HttpNotFound());
            }
        }
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                // Скрыть Grid
                grid.Visibility = Visibility.Hidden;
                MContext    mc  = new MContext();
                Subcategory sub = mc.Subcategories.First(x => x.ID == s.ID_Subcategory);
                PriceFormat pf  = mc.PriceFormat.First(x => x.ID == sub.ID_PriceFormat);
                // Увеличить размер в 5 раз
                MyCanvas.LayoutTransform = new ScaleTransform(pf.TransX, pf.TransY);
                // Определить поля
                int pageMargin = pf.Margin;

                // Получить размер страницы
                System.Windows.Size pageSize = new System.Windows.Size(pf.X, pf.Y);
                // Инициировать установку размера элемента
                MyCanvas.Measure(pageSize);
                MyCanvas.Arrange(new Rect(pageMargin, pageMargin, pageSize.Width, pageSize.Height));

                // Напечатать элемент
                printDialog.PrintVisual(MyCanvas, "Распечатываем элемент Canvas");

                // Удалить трансформацию и снова сделать элемент видимым
                MyCanvas.LayoutTransform = null;
                grid.Visibility          = Visibility.Visible;
                if (s.TotalPrice != 0)
                {
                    SKU stmp = mc.SKUs.First(x => x.ID == s.ID);
                    stmp.Price       = s.TotalPrice;
                    stmp.TotalPrice  = 0;
                    stmp.Promo       = s.TotalPromo;
                    stmp.ChangePrice = false;
                    mc.SaveChanges();
                }
            }
            this.Close();
        }
Example #6
0
 void FSerch(int id)
 {
     try
     {
         MContext mc = new MContext();
         if (mc.SKUs.Any(x => x.ID == id))
         {
             SKU     s    = mc.SKUs.First(x => x.ID == id);
             InfoSKU asku = new InfoSKU(s);
             asku.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Товар с таким ID не найден");
         }
     }
     catch
     {
         MessageBox.Show("Введен не корректный ID");
         IDNumber.Clear();
     }
 }
Example #7
0
        void Set(SKU s)
        {
            MContext mc = new MContext();

            this.Title     = s.Name;
            LID.Content    = string.Format("{0}", s.ID);
            LSub.Content   = mc.Subcategories.First(x => x.ID == s.ID_Subcategory).Name;
            LBre.Content   = mc.Brends.First(x => x.ID == s.ID_Brend).Name;
            LMod.Content   = s.Name;
            LPrice.Content = string.Format("{0}", s.Price);
            LInput.Content = string.Format("{0}", s.InputPrice);
            LMarga.Content = string.Format("{0} %", Math.Round(((s.Price / s.InputPrice) - 1) * 100, 2));
            if (s.Enable)
            {
                BEnable.Content    = "В наличии";
                BEnable.Background = Brushes.GreenYellow;
            }
            else
            {
                BEnable.Content    = "Нет в наличи";
                BEnable.Background = Brushes.Red;
            }
        }
Example #8
0
        public static HttpStatusCode AddSastojci(SastojciPostWithImage ns)
        {
            MContext ctx = new MContext();

            Sastojci isExists = ctx.Sastojci.FirstOrDefault(x => x.Naziv == ns.Naziv && x.IsDeleted == false);

            if (isExists != null)
            {
                return(HttpStatusCode.Conflict);
            }

            Sastojci noviSastojak = new Sastojci();

            noviSastojak.BrojKalorija    = ns.BrojKalorija;
            noviSastojak.Cijena          = ns.Cijena;
            noviSastojak.Gramaza         = ns.Gramaza;
            noviSastojak.IsDeleted       = false;
            noviSastojak.Napomena        = ns.Napomena;
            noviSastojak.Naziv           = ns.Naziv;
            noviSastojak.VrstaSastojkaId = ns.VrstaSastojkaId;

            ctx.Sastojci.Add(noviSastojak);

            ctx.SaveChanges();

            if (ns.Slika != null)
            {
                Slike novaSlika = new Slike();
                novaSlika.UrlSlike   = "/";
                novaSlika.Slika      = ns.Slika;
                novaSlika.SastojakId = noviSastojak.Id;
                ctx.Slike.Add(novaSlika);
                ctx.SaveChanges();
            }

            return(HttpStatusCode.OK);
        }
Example #9
0
        public ActionResult Enroll()
        {
            //Course Name List
            MContext s_context = new MContext();
            //var CourseNameList = s_context.DbSetCourses.ToList();
            //SelectList CNamelist = new SelectList(CourseNameList, "CourseID", "Name");
            //ViewBag.CList = CNamelist;

            //Course Number List
            var        CourseNumberList = s_context.DbSetCourses.ToList();
            SelectList CNumlist         = new SelectList(CourseNumberList, "CourseID", "CourseNumber");

            ViewBag.CNList = CNumlist;

            //var s = s_context.DbSetEnrollments.FirstOrDefault(i => i.student.StudentID == id);

            //Student Name List
            //var StudentNameList = s_context.DbSetStudents.ToList();
            //SelectList SNamelist = new SelectList(StudentNameList, "StudentID", "Name");
            //ViewBag.SList = SNamelist;

            //Student Number List
            var        StudentNumberList = s_context.DbSetStudents.ToList();
            SelectList SNumlist          = new SelectList(StudentNumberList, "StudentID", "EnrollmentNumber");

            ViewBag.SNList = SNumlist;

            ////////////////////////////////////////////////////////////////////////////////////////

            //var sn = Convert.ToInt32(Request.Form["Enrollment Number"]);
            //var s = GetStudent(sn);
            //Enrollment e = new Enrollment();
            //e.student = s;
            //return View(e);

            return(View());
        }
Example #10
0
        public NewParsing(List <SKU> list)
        {
            InitializeComponent();
            MContext           mc = new MContext();
            List <Subcategory> ls = mc.Subcategories.ToList();

            CheckSubcategory.ItemsSource = ls.OrderBy(x => x.Name);
            BitmapImage bi = new BitmapImage(new Uri("D:\\logo.ico"));

            this.Icon            = bi;
            this.list            = list;
            NComfy.Content       = "EK";
            NRozetka.Visibility  = Visibility.Hidden;
            PRozetka.Visibility  = Visibility.Hidden;
            LRozetka.Visibility  = Visibility.Hidden;
            NAllo.Visibility     = Visibility.Hidden;
            PAllo.Visibility     = Visibility.Hidden;
            LAllo.Visibility     = Visibility.Hidden;
            NEldorado.Visibility = Visibility.Hidden;
            PEldorado.Visibility = Visibility.Hidden;
            LEldorado.Visibility = Visibility.Hidden;
            Start.Visibility     = Visibility.Hidden;
            EKStart.Visibility   = Visibility.Visible;
        }
Example #11
0
        public static HttpStatusCode DeleteKorpaItem(int korpaId, int salataId)
        {
            MContext ctx = new MContext();

            KorpaStavke ks = ctx.KorpaStavke.FirstOrDefault(x => x.SalataId == salataId && x.KorpaId == korpaId);

            if (ks != null)
            {
                ctx.KorpaStavke.Remove(ks);
            }
            else
            {
                return(HttpStatusCode.NoContent);
            }
            ctx.SaveChanges();

            //// Brisanje stavki salate
            //List<SalataStavke> lss = ctx.SalataStavke.Where(x => x.SalataId == salataId).ToList();
            //if (lss.Count == 0)
            //    return HttpStatusCode.NoContent;
            //ctx.SalataStavke.RemoveRange(lss);
            //ctx.SaveChanges();

            //// Brisanje ocjena i komentara
            //OcjeneKomentari ok = ctx.OcjeneKomentari.FirstOrDefault(x => x.SalataId == salataId);
            //if (ok != null) ctx.OcjeneKomentari.Remove(ok);
            //ctx.SaveChanges();

            //// Brisanje salate
            //Salate s = ctx.Salate.FirstOrDefault(x => x.Id == salataId);
            //if (s != null) ctx.Salate.Remove(s);
            //else return HttpStatusCode.NoContent;
            //ctx.SaveChanges();

            return(HttpStatusCode.OK);
        }
        public void GetEventLogWhenFilterNotNull()
        {
            using (var context = new MContext(_options))
            {
                //arrange
                _dataRepository = new DataRepository(context);

                //act when DateFrom.HasValue
                var result = _dataRepository.GetEventLog(new FilterDto {
                    DateFrom = DateTime.Now.AddDays(1)
                });
                AssertType(result);
                Assert.AreEqual(5, result.Count);

                //act when DateTo.HasValue
                result = _dataRepository.GetEventLog(new FilterDto {
                    DateTo = DateTime.Now.AddDays(3)
                });
                AssertType(result);
                Assert.AreEqual(3, result.Count);

                //act when Type not null
                result = _dataRepository.GetEventLog(new FilterDto {
                    Type = EventTypeEnum.Sms
                });
                AssertType(result);
                Assert.IsFalse(result.Any(a => a.EventType == EventTypeEnum.Call));

                //act when passed filter should return count zero
                result = _dataRepository.GetEventLog(new FilterDto {
                    DateFrom = DateTime.Now, DateTo = DateTime.Now, Type = "MMS"
                });
                AssertType(result);
                Assert.AreEqual(0, result.Count);
            }
        }
Example #13
0
        internal Result(QueryResultSet rs, C4QueryEnumerator *e, MContext context)
        {
            _rs             = rs;
            _context        = context;
            _columns        = e->columns;
            _missingColumns = new BitArray(BitConverter.GetBytes(e->missingColumns));
            _columnNames    = new Dictionary <string, int>(_rs.ColumnNames);
            foreach (var pair in _rs.ColumnNames)
            {
                if (pair.Value < _missingColumns.Length && _missingColumns.Get(pair.Value))
                {
                    _columnNames.Remove(pair.Key);
                }
            }

            _deserialized = new object[_rs.ColumnNames.Count];
            for (int i = 0; i < _rs.ColumnNames.Count; i++)
            {
                if (!_missingColumns.Get(i))
                {
                    _deserialized[i] = FleeceValueToObject(i);
                }
            }
        }
Example #14
0
        //public AnaliticSku(List<SKU> ls)
        //{
        //    //в конструкторе лист ску для обработки товаров не имеющихся у прямых конкуренотов
        //    InitializeComponent();
        //    Thread th = new Thread(SetProg);
        //    th.Start();
        //    Thread th2 = new Thread(EK);
        //    th2.Start(ls);
        //}
        void Analitics(object o)
        {
            //процесс анализа
            MContext mc = new MContext();
            var      ls = mc.SKUs.Where(x => x.Enable == true);
            int      i  = 0;

            foreach (SKU s in ls.ToList())
            {
                List <Subcategory> sub = mc.Subcategories.Where(x => x.ID == s.ID_Subcategory).ToList();

                int TotalPrice = 0;
                TotalPrice = s.ComfyPrice + sub[0].DeliveryPriceComfy;
                int TotalPromo = 0;
                TotalPromo = s.ComfyPromo;
                string sWho     = "Comfy";
                int    delivery = sub[0].DeliveryPriceComfy;
                if (TotalPrice - delivery == 0)
                {
                    TotalPrice = s.EldoradoPrice + sub[0].DeliveryPriceEldorado;
                    TotalPromo = 0;
                    delivery   = sub[0].DeliveryPriceEldorado;
                    sWho       = "Eldorado";
                }
                else
                {
                    if (((s.EldoradoPrice + sub[0].DeliveryPriceEldorado) < TotalPrice - (TotalPrice * TotalPromo) / 100) && s.EldoradoPrice != 0)
                    {
                        TotalPrice = s.EldoradoPrice + sub[0].DeliveryPriceEldorado;
                        TotalPromo = 0;
                        delivery   = sub[0].DeliveryPriceEldorado;
                        sWho       = "Eldorado";
                    }
                }
                if (TotalPrice - delivery == 0)
                {
                    TotalPrice = s.AlloPrice + sub[0].DeliveryPriceAllo;
                    TotalPromo = 0;
                    delivery   = sub[0].DeliveryPriceAllo;
                    sWho       = "Allo";
                }
                else
                {
                    if (((s.AlloPrice + sub[0].DeliveryPriceAllo) < TotalPrice - (TotalPrice * TotalPromo) / 100) && s.AlloPrice != 0)
                    {
                        TotalPrice = s.AlloPrice + sub[0].DeliveryPriceAllo;
                        TotalPromo = 0;
                        delivery   = sub[0].DeliveryPriceAllo;
                        sWho       = "Allo";
                    }
                }
                if (TotalPrice - delivery == 0)
                {
                    TotalPrice = s.RozetkaPrice + sub[0].DeliveryPriceRozetka;
                    TotalPromo = 0;
                    delivery   = sub[0].DeliveryPriceRozetka;
                    sWho       = "Rozetka";
                }
                else
                {
                    if (((s.RozetkaPrice + sub[0].DeliveryPriceRozetka) < TotalPrice - (TotalPrice * TotalPromo) / 100) && s.RozetkaPrice != 0)
                    {
                        TotalPrice = s.RozetkaPrice + sub[0].DeliveryPriceRozetka;
                        TotalPromo = 0;
                        delivery   = sub[0].DeliveryPriceRozetka;
                        sWho       = "Rozetka";
                    }
                }
                s.TotalPrice = TotalPrice;
                s.TotalPromo = TotalPromo;
                if ((TotalPrice - delivery) != 0)
                {
                    if (TotalPrice != s.Price)
                    {
                        s.ChangePrice = true;
                        s.Who         = sWho;
                    }
                }
                else
                {
                    s.TotalPrice = 0;
                    s.TotalPromo = 0;
                }
                mc.SaveChanges();
                Procent = (int)(i * 100 / ls.ToList().Count);
                i++;
            }
            Procent = 100;
            MessageBox.Show("Анализ завершен");
            OK.Dispatcher.Invoke(new Action(() => { OK.IsEnabled = true; }));
        }
Example #15
0
        private void ShowSKUs_Click(object sender, RoutedEventArgs e)
        {
            MContext mc = new MContext();
            List <MyGridMainMenu> lsku = null;

            if (CBCategory.SelectedIndex == -1)
            {
                lsku = mc.SKUs.Select(x => new MyGridMainMenu
                {
                    ID           = x.ID,
                    Категория    = x.Subcategory.Category.Name,
                    Подкатегория = x.Subcategory.Name,
                    Бренд        = x.Brend.Name,
                    Модель       = x.Name,
                    Вход         = x.InputPrice,
                    озница       = x.Price,
                    Наценка      = Math.Round(((x.Price / x.InputPrice) - 1) * 100, 2),
                    Наличие      = x.Enable
                }).ToList();
            }
            else if (CBSubcategory.SelectedIndex == -1)
            {
                Category c = CBCategory.SelectedItem as Category;
                lsku = mc.SKUs.Where(x => x.Subcategory.ID_Category == c.ID).Select(x => new MyGridMainMenu
                {
                    ID           = x.ID,
                    Категория    = x.Subcategory.Category.Name,
                    Подкатегория = x.Subcategory.Name,
                    Бренд        = x.Brend.Name,
                    Модель       = x.Name,
                    Вход         = x.InputPrice,
                    озница       = x.Price,
                    Наценка      = Math.Round(((x.Price / x.InputPrice) - 1) * 100, 2),
                    Наличие      = x.Enable
                }).ToList();
            }
            else if (CBBrend.SelectedIndex == -1)
            {
                Subcategory s = CBSubcategory.SelectedItem as Subcategory;
                lsku = mc.SKUs.Where(x => x.ID_Subcategory == s.ID).Select(x => new MyGridMainMenu
                {
                    ID           = x.ID,
                    Категория    = x.Subcategory.Category.Name,
                    Подкатегория = x.Subcategory.Name,
                    Бренд        = x.Brend.Name,
                    Модель       = x.Name,
                    Вход         = x.InputPrice,
                    озница       = x.Price,
                    Наценка      = Math.Round(((x.Price / x.InputPrice) - 1) * 100, 2),
                    Наличие      = x.Enable
                }).ToList();
            }
            else
            {
                Subcategory s = CBSubcategory.SelectedItem as Subcategory;
                Brend       b = CBBrend.SelectedItem as Brend;

                lsku = mc.SKUs.Where(x => x.ID_Subcategory == s.ID && x.ID_Brend == b.ID).Select(x => new MyGridMainMenu
                {
                    ID           = x.ID,
                    Категория    = x.Subcategory.Category.Name,
                    Подкатегория = x.Subcategory.Name,
                    Бренд        = x.Brend.Name,
                    Модель       = x.Name,
                    Вход         = x.InputPrice,
                    озница       = x.Price,
                    Наценка      = Math.Round(((x.Price / x.InputPrice) - 1) * 100, 2),
                    Наличие      = x.Enable
                }).ToList();
            }


            //предусмотреть варианты не выбранных крмбобоксов



            if (lsku != null)
            {
                DGS.ItemsSource = lsku;
            }
        }
 public ModelController(MContext context)
 {
     Mcontext = context;
 }
Example #17
0
 public RegionsController(MContext context)
 {
     _context = context;
 }
Example #18
0
 public PlayersController(MContext context)
 {
     _context = context;
 }
Example #19
0
 public StagesController(MContext context)
 {
     _context = context;
 }
Example #20
0
        public static List <Korisnici> GetKorisnici()
        {
            MContext ctx = new MContext();

            return(ctx.Korisnici.ToList());
        }
 public PlayersPositionsController(MContext context)
 {
     _context = context;
 }
Example #22
0
        public static Korisnici GetKorisnik(AccountLoginVm account)
        {
            MContext ctx = new MContext();

            return(ctx.Korisnici.FirstOrDefault(x => x.Email == account.UserName && x.LozinkaHash == account.Lozinka));
        }
Example #23
0
 public CoachesController(MContext context)
 {
     _context = context;
 }
Example #24
0
        public static Korisnici GetKorisnikById(int korisnikId)
        {
            MContext ctx = new MContext();

            return(ctx.Korisnici.FirstOrDefault(x => x.Id == korisnikId));
        }
Example #25
0
 public MRoot(MContext context, FLValue *value, bool isMutable)
     : base(context, isMutable)
 {
     _slot = new MValue(value);
 }
Example #26
0
 public JogoRepository(MContext context)
 {
     this._context = context;
 }
Example #27
0
 public MRoot(MContext context, bool isMutable = true)
     : this(context, NativeRaw.FLValue_FromData(context.Data, FLTrust.Untrusted), isMutable)
 {
 }
Example #28
0
 public GeneroRepository(MContext context)
 {
     this._context = context;
 }
Example #29
0
        public static List <Sastojci> GetOmiljeni(string vrstaSastojka = "")
        {
            MContext ctx = new MContext();

            return(vrstaSastojka == "" ? ctx.Sastojci.Where(x => x.IsDeleted == false).ToList() : ctx.Sastojci.Where(x => x.IsDeleted == false && x.VrstaSastojka.Naziv.ToLower() == vrstaSastojka.ToLower()).ToList());
        }
Example #30
0
 public DataRepository(MContext context)
 {
     _context = context;
 }