Ejemplo n.º 1
0
 public static void InsertToTable(int userId)
 {
     try
     {
         using (var context = new NomadContext())
         {
             context.Deliveries.Add(new Delivery
             {
                 UserId       = userId,
                 DeadLineDate = DateTime.Now.AddDays(10),
                 Status       = "Не доставлено"
             });
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }
Ejemplo n.º 2
0
        public static string CheckForAvailabilityPassword(string data)
        {
            string password = "";

            try
            {
                using (var context = new NomadContext())
                {
                    password = context.Users
                               .Where(u => u.Login == data)
                               .Select(u => u.Password).FirstOrDefault();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            return(password);
        }
Ejemplo n.º 3
0
        public static int GetUserId(string login)
        {
            int id = 0;

            try
            {
                using (var context = new NomadContext())
                {
                    id = context.Users
                         .Where(u => u.Login == login)
                         .Select(u => u.Id).FirstOrDefault();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            return(id);
        }
Ejemplo n.º 4
0
 public static void InsertToTable(int months, int userId)
 {
     try
     {
         using (var context = new NomadContext())
         {
             context.SubscriptionLogs.Add(new SubscriptionLog
             {
                 UserId            = userId,
                 SubscriptionStart = DateTime.Now,
                 SubscriptionEnd   = DateTime.Now.AddMonths(months),
                 PricePerMonth     = 100,
                 MagazinePrice     = 75
             });
             context.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }