Esempio n. 1
0
        public IActionResult Registration(DbUser u)
        {
            using (var db = new MotiveOfficeDBContext())
            {
                db.Users.Add(u);
                db.SaveChanges();
            }

            return(View("Index"));
        }
Esempio n. 2
0
 public IActionResult ChangeTarif(int id)
 {
     using (var db = new MotiveOfficeDBContext())
     {
         db.Users.Load();
         db.PhonePlans.Load();
         var user = db.Users.Find(getId());
         user.PlanCode = id;
         user.Plan     = db.PhonePlans.Find(id);
         db.SaveChanges();
         return(View("logged", user));
     }
 }
Esempio n. 3
0
        public IActionResult UpdateServices(int[] service)
        {
            using (var db = new MotiveOfficeDBContext())
            {
                db.Users.Load();
                db.DbServices.Load();
                var    i = 0;
                DbUser user;
                try
                {
                    user = db.Users.Find(getId());
                    var list = new List <DbService>();
                    if (user.Services != null)
                    {
                        user.Services.Clear();
                        db.SaveChanges();
                    }
                    foreach (var e in service)
                    {
                        db.DbServices.Add(new DbService()
                        {
                            UserId = user.Id, Id = ++i, ServiceId = e
                        });
                        //list.Add(new DbService() {UserId = user.Id, ServiceId = e });
                        //user.Services.Append(new DbService() {UserId = user.Id, ServiceId = e });
                    }
                    //else user.Services = new System.Collections.ObjectModel.Collection<DbService>(list);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(View("BadLogin"));
                }

                return(View("index"));
            }
        }
Esempio n. 4
0
        public IActionResult AskQuestion(string answ, string passwordHash, int id)
        {
            using (var db = new MotiveOfficeDBContext())
            {
                db.Users.Load();
                var user = db.Users.Find(id);
                if (user.SecretAnswer == answ)
                {
                    user.PasswordHash = passwordHash;
                    db.SaveChanges();
                    return(View("index"));
                }

                return(View("BadLogin"));
            }
        }