public IHttpActionResult PutUserGroup(int id, UserGroup userGroup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != userGroup.Id)
            {
                return BadRequest();
            }

            db.Entry(userGroup).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserGroupExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostUserGroup(UserGroup userGroup)
        {
            if (!ModelState.IsValid || !Membership.ValidateUser(userGroup.Name, userGroup.Password))
            {
                return BadRequest(ModelState);
            }

            var token = db.UserGroups.First(_ => _.Name == userGroup.Name && _.Password == userGroup.Password).AppToken;

            userGroup.AppToken = token;

            return Ok(userGroup);
        }
        public ActionResult SignIn(UserGroup model)
        {
            try
            {
                if (!Membership.ValidateUser(model.Name, model.Password))
                {
                    return RedirectToAction("SignIn", "Authorization");
                }

                FormsAuthentication.SetAuthCookie(model.Name, false);
                return RedirectToAction("Index", "Chat");
            }
            catch (Exception exception)
            {
                return View(model);
            }
        }
        public ActionResult SignUp(UserGroup model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.AppToken = Guid.NewGuid().ToString().Replace("-", string.Empty);
                    _context.UserGroups.Add(model);
                    _context.SaveChanges();

                    return RedirectToAction("Index", "Home");
                }
                catch (Exception e)
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            return View(model);
        }