Example #1
0
 public virtual void Added(TEntity entity)
 {
     dbcontext.Configuration.AutoDetectChangesEnabled = false;
     dbcontext.Entry(entity).State = EntityState.Added;
     dbcontext.ChangeTracker.DetectChanges();
     dbcontext.SaveChanges();
     dbcontext.Configuration.AutoDetectChangesEnabled = true;
 }
Example #2
0
        public async Task <Order> SaveBooking(int ord, int status)
        {
            //Проверить что все заполнено, потом изменять статус
            Order order = db.Orders.Find(ord);

            order.StatusId        = status;
            db.Entry(order).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(order);
        }
Example #3
0
        public async Task <Order> SaveGood(int GoodID, int OrdID, decimal Quantity)
        {
            Order order = await db.Orders.FindAsync(OrdID);

            OrderProduct products;

            if (order.Step == 0)
            {
                //Значит 1е внесение
                products = new OrderProduct();
            }
            else
            {
                products = await db.OrderProducts.FirstOrDefaultAsync(a => a.OrderId == OrdID);
            }
            products.GoodId  = GoodID;
            products.OrderId = OrdID;
            products.Quant   = Quantity;
            if (products.OrderProductId == 0)
            {
                db.OrderProducts.Add(products);
            }
            else
            {
                db.Entry(products).State = EntityState.Modified;
            }
            int iddet = await db.SaveChangesAsync();

            return(order);
        }
Example #4
0
        public async Task <int> DelPerson(int id)
        {
            Person person = await db.Persons.FindAsync(id);

            person.IsMark          = 1;
            db.Entry(person).State = EntityState.Modified;
            return(await db.SaveChangesAsync());
        }
Example #5
0
        public async Task <int> Save(OrderView sv)
        {
            //Проверить что все заполнено, потом изменять статус
            Order order = new Order();

            order.OrderId    = sv.OrderId;
            order.CustId     = sv.CustId;
            order.AdresId    = sv.AdresId;
            order.Centr      = sv.Centr;
            order.ContractId = sv.ContractId;
            if (sv.CDat == null)
            {
                order.DateExec = DateTime.Now;
            }
            else
            {
                order.DateExec = StringToDate.Date(sv.CDat);
            }
            order.PersonId       = sv.PersonId;
            order.note           = sv.Note;
            order.insDate        = DateTime.Now;
            order.isOnlinePay    = sv.isOnlinePay;
            order.StatusId       = sv.StatusId;
            order.Invoice        = sv.Invoice;
            order.RelatedOrderId = sv.RelatedOrderId;

            order.email = sv.email;

            if (order.OrderId == 0)
            {
                db.Orders.Add(order);
            }
            else
            {
                db.Entry(order).State = EntityState.Modified;
            }

            await db.SaveChangesAsync();

            return(order.OrderId);
        }
Example #6
0
        public void CustUser(string userId, int custId, string ip, string adres)
        {
            Statistic statistic = new Statistic();

            statistic.CustID    = custId;
            statistic.UserId    = userId;
            statistic.UserAdres = ip;
            statistic.UserHost  = adres;
            db.Statistics.Add(statistic);
            UserInCust userInCust = db.UserInCusts.FirstOrDefault(u => u.UserId == userId && u.CustID == custId);

            if (userInCust != null)
            {
                userInCust.LastDat         = DateTime.Now;
                db.Entry(userInCust).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Example #7
0
 public ActionResult ForgotPassword(ForgotPasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         AbzContext db   = new AbzContext();
         Usr        user = db.Users.FirstOrDefault(u => u.Email == model.Email);
         if (user == null)
         {
             return(View("Error"));
         }
         string NewPassword = GenerateRandomPassword(6);
         user.Password        = NewPassword;
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         EmailSend.EMailFPassw(model.Email, NewPassword);
         return(View("ForgotPasswordConfirmation"));
     }
     return(View(model));
 }
Example #8
0
        public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AbzHashRepo hashRepo = new AbzHashRepo();
            string      auth     = GetCookie("Auth");
            AbzHash     abzHash  = hashRepo.GetHash(auth);
            AbzContext  db       = new AbzContext();
            Usr         usr      = db.Users.FirstOrDefault(u => u.Email == abzHash.Email);

            if ((usr != null) && (usr.Password == model.OldPassword))
            {
                usr.Password        = model.NewPassword;
                db.Entry(usr).State = EntityState.Modified;
                db.SaveChanges();
                await EmailSend.EMailRegAsync(abzHash.Email, model.NewPassword);
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #9
0
        public async Task <int> SaveDetail(int id, List <TrustTecDet> det)
        {
            foreach (var item in det)
            {
                TrustTecDet tecDet = new TrustTecDet();
                tecDet.TrustTecDetId = item.TrustTecDetId;
                tecDet.TrustTecId    = id;
                tecDet.TecModel      = item.TecModel;
                tecDet.Gn            = item.Gn;
                tecDet.Driv          = item.Driv;

                if (tecDet.TrustTecDetId == 0)
                {
                    db.TrustTecDets.Add(tecDet);
                }
                else
                {
                    db.Entry(tecDet).State = EntityState.Modified;
                }
            }
            int iddet = await db.SaveChangesAsync();

            return(iddet);
        }
Example #10
0
 public void UpdateHash(AbzHash hash)
 {
     db.Entry(hash).State = EntityState.Modified;
     db.SaveChanges();
 }