Exemple #1
0
 public static void SetWin(int Id, string WinId)
 {
     using (CourseEntitiesDB db = new CourseEntitiesDB())
     {
         db.Database.ExecuteSqlCommand("UPDATE dbo.Lots SET IdWin = {1} WHERE Id = {0}", Id, WinId);
         db.SaveChanges();
     }
 }
Exemple #2
0
 public static void Change(Lot lot)
 {
     using (CourseEntitiesDB db = new CourseEntitiesDB())
     {
         LotsMeth.DeleteLot(lot.Id);
         db.Lots.Add(lot);
         db.SaveChanges();
     }
 }
Exemple #3
0
 public static bool SetRealPrice(int Id, decimal RealPrice)
 {
     using (CourseEntitiesDB db = new CourseEntitiesDB())
     {
         db.Database.ExecuteSqlCommand("UPDATE dbo.Lots SET IdWin = {0} WHERE Id = {1} AND RealPrice < {2}", HttpContext.Current.User.Identity.GetUserId(), Id, RealPrice);
         db.Database.ExecuteSqlCommand("UPDATE dbo.Lots SET RealPrice = {0} WHERE Id = {1} AND RealPrice < {2}", RealPrice, Id, RealPrice);
         db.SaveChanges();
         return(true);
     }
 }
Exemple #4
0
 public static void DeleteLot(int Id)
 {
     using (CourseEntitiesDB db = new CourseEntitiesDB())
     {
         foreach (Lot lot in db.Lots)
         {
             if (lot.Id == Id && lot.IsActive)
             {
                 db.Lots.Remove(lot);
             }
         }
         db.SaveChanges();
     }
 }
Exemple #5
0
        public static bool Add(string Name, string Type, byte[] Image, decimal MinPrice, decimal RealPrice, System.DateTime TimeStart, System.DateTime TimeEnd)
        {
            using (var db = new CourseEntitiesDB())
            {
                db.Lots.Add(new Lot
                {
                    Id        = db.Lots.Count() + 1,
                    UserId    = HttpContext.Current.User.Identity.GetUserId(),
                    Name      = Name,
                    Type      = Type,
                    Image     = Image,
                    MinPrice  = MinPrice,
                    RealPrice = RealPrice,
                    TimeEnd   = TimeEnd,
                    TimeStart = TimeStart,
                    IsActive  = true
                });

                db.SaveChanges();
            }
            return(true);
        }