Exemplo n.º 1
0
 public async Task <JsonResult> AddGild(Gild gild)
 {
     Gild    = new EFRepository <Gild>(new ApplicationDbContext());
     product = new EFRepository <Product>(new ApplicationDbContext());
     if (gild.Id != 0)
     {
         gild.Name = Gild.FindById(gild.Id).Name;
     }
     else
     {
         gild.Name = product.FindById(gild.ProductId.Value).Name;
     }
     gild.State = sklad.GildAdd(gild, 0);
     return(Json(gild, JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 2
0
 public async Task <JsonResult> AddSpecGild(Gild gild, double CountCon)
 {
     Gild        = new EFRepository <Gild>(new ApplicationDbContext());
     Condimentss = new EFRepository <Condiments>(new ApplicationDbContext());
     if (gild.Id != 0)
     {
         gild.Name = Gild.FindById(gild.Id).Name;
     }
     else
     {
         gild.Name = Condimentss.FindById(gild.CondimentsId.Value).Name;
     }
     gild.Count = int.Parse(CountCon.ToString());
     gild.State = sklad.GildAdd(gild, CountCon);
     return(Json(gild, JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 3
0
 public Task ModGild(Gild gild, double Con)
 {
     Condiments = new EFRepository <Condiments>(new ApplicationDbContext());
     return(Task.Run(() =>
     {
         var prod = product.FindById(gild.ProductId.Value);
         prod.Count -= gild.Count;
         Task.Factory.StartNew(() =>
         {
             product.Update(prod);
         }).Wait();
         var gld = Gild.FindById(gild.Id);
         gild.Count += gld.Count;
         Task.Factory.StartNew(() =>
         {
             Gild.Update(gild);
         }).Wait();
         var con = Condiments.FindById(gild.CondimentsId.Value);
         con.Count -= Con;
         Task.Factory.StartNew(() =>
         {
             Condiments.Update(con);
         }).Wait();
         GildStatic gl = new GildStatic();
         gl.Date = DateTime.Now;
         gl.CountGild = gild.Count;
         gl.CountCondiments = Con;
         Task.Factory.StartNew(() =>
         {
             GildStatic.Create(gl);
         }).Wait();
         var b = GildStatic.Get(x => x.CountGild == gl.CountGild && x.Date.Day == gl.Date.Day && x.Date.Month == gl.Date.Month && x.Date.Year == gl.Date.Year && x.Date.Hour == gl.Date.Hour && x.Date.Minute == gl.Date.Minute && x.Date.Second == gl.Date.Second).First();
         Task.Factory.StartNew(() =>
         {
             Gild_GildStatic.Create(new db.Gild_GildStatic()
             {
                 GildId = gild.Id, GildStaticId = b.Id
             });
         }).Wait();
     }));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Добавление гильдии
        /// </summary>
        /// <param name="gild"></param>
        public bool GildAdd(Gild gild, double Con)
        {
            Condiments = new EFRepository <Condiments>(new ApplicationDbContext());
            GildStatic gl = new GildStatic();

            if (gild.ProductId != null)
            {
                var prod = product.FindById(gild.ProductId.Value);
                gild.Name   = prod.Name;
                prod.Count -= gild.Count;
                if (prod.Count < 0)
                {
                    return(false);
                }

                Task.Factory.StartNew(() =>
                {
                    product.Update(prod);
                }).Wait();
            }
            else
            {
                var con = Condiments.FindById(gild.CondimentsId.Value);
                con.Count -= Con;
                if (con.Count < 0)
                {
                    return(false);
                }
                Task.Factory.StartNew(() =>
                {
                    Condiments.Update(con);
                }).Wait();
                var sp = Condiments.FindById(gild.CondimentsId.Value);
                gild.Name = sp.Name;
            }
            if (Gild.Get(x => x.Name == gild.Name).Any())
            {
                var gls = Gild.Get(x => x.Name == gild.Name).First();

                if (gild.ProductId != null)
                {
                    gls.Count   += gild.Count;
                    gl.CountGild = gild.Count;
                }
                else
                {
                    gls.Count         += int.Parse(Con.ToString());
                    gl.CountGild       = Con;
                    gl.CountCondiments = Con;
                }
                Task.Factory.StartNew(() =>
                {
                    Gild.Update(gls);
                }).Wait();
                gl.Date = DateTime.Now;
                Task.Factory.StartNew(() =>
                {
                    GildStatic.Create(gl);
                }).Wait();
                GildStatic b = GildStatic.Get(x => x.CountGild == gl.CountGild && x.Date.Day == gl.Date.Day && x.Date.Month == gl.Date.Month && x.Date.Year == gl.Date.Year && x.Date.Hour == gl.Date.Hour && x.Date.Minute == gl.Date.Minute && x.Date.Second == gl.Date.Second).First();
                Task.Factory.StartNew(() =>
                {
                    Gild_GildStatic.Create(new db.Gild_GildStatic()
                    {
                        GildId = gls.Id, GildStaticId = b.Id
                    });
                }).Wait();
                return(true);
            }
            else
            {
                if (gild.ProductId != null)
                {
                    gl.CountGild = gild.Count;
                }
                else
                {
                    gild.Count  += int.Parse(Con.ToString());
                    gl.CountGild = Con;
                }
                Task.Factory.StartNew(() =>
                {
                    Gild.Create(gild);
                }).Wait();
                gl.Date = DateTime.Now;
                Task.Factory.StartNew(() =>
                {
                    GildStatic.Create(gl);
                }).Wait();
                var        a = Gild.Get(x => x.Name == gild.Name && x.Count == gild.Count).First();
                GildStatic b = GildStatic.Get(x => x.CountGild == gl.CountGild && x.Date.Day == gl.Date.Day && x.Date.Month == gl.Date.Month && x.Date.Year == gl.Date.Year && x.Date.Hour == gl.Date.Hour && x.Date.Minute == gl.Date.Minute && x.Date.Second == gl.Date.Second).First();
                Task.Factory.StartNew(() =>
                {
                    Gild_GildStatic.Create(new db.Gild_GildStatic()
                    {
                        GildId = a.Id, GildStaticId = b.Id
                    });
                }).Wait();
                return(true);
            }
        }
Exemplo n.º 5
0
        public async Task <JsonResult> PrihGild(Gild gild, double CountCon)
        {
            await sklad.ModGild(gild, CountCon);

            return(Json(gild, JsonRequestBehavior.AllowGet));
        }