Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,RoomId,Name,Status,Version")] Device device)
        {
            if (ModelState.IsValid)
            {
                _db.Devices.Add(device);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RoomId = new SelectList(_db.Rooms, "Id", "Name", device.RoomId);
            return(View(device));
        }
Exemplo n.º 2
0
        public Client Register(ClientSignUp clientSignUp)
        {
            Client client = new Client();

            if (dbContext.client.Where(c => c.login == clientSignUp.login).Any())
            {
                client = null;
            }
            else
            {
                Client cTmp = dbContext.client.FirstOrDefault();

                if (cTmp != null)
                {
                    Console.WriteLine(cTmp.id_client);
                    var maxId = dbContext.client.Max(c => c.id_client);
                    client.id_client = maxId + 1;
                }
                else
                {
                    Console.WriteLine("baza jest pusta");
                    client.id_client = 0;
                }
                var salt     = CreateSalt();
                var password = Create(clientSignUp.password, salt);
                client.login    = clientSignUp.login;
                client.email    = clientSignUp.email;
                client.password = password;
                client.salt     = salt;

                dbContext.client.Add(client);
                //dbContext.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT Client ON");
                dbContext.SaveChanges();
            }
            return(client);
        }
Exemplo n.º 3
0
 public void Save()
 {
     _dbContext.SaveChanges();
 }
Exemplo n.º 4
0
 public int Commit()
 {
     return(context.SaveChanges());
 }