Beispiel #1
0
        public ActionResult Login(UserAccessViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AccessRequest oAR = new AccessRequest();

            oAR.Email    = model.Email;
            oAR.Password = UtilitiesChat.Tools.Encrypt.GetSHA256(model.Password);

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply =
                oRequestUtil.Execute <AccessRequest>(Constants.Url.ACCESS, "Post", oAR);

            UtilitiesChat.Models.WS.UserResponse oUserResponse =
                JsonConvert.DeserializeObject <UtilitiesChat.Models.WS.UserResponse>(JsonConvert.SerializeObject(oReply.data));

            if (oReply.result == 1)
            {
                Session["User"] = oUserResponse;
                return(RedirectToAction("Index", "Lobby"));
            }

            ViewBag.error = "Datos incorrectos";

            return(View());
        }
Beispiel #2
0
        public ActionResult Messages(int id)
        {
            GetSession();

            List <MessagesResponse> lst = new List <MessagesResponse>();

            MessagesRequest oMessagesRequest = new MessagesRequest();

            oMessagesRequest.AccessToken = oUserSession.AccessToken;
            oMessagesRequest.IdRoom      = id;

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply =
                oRequestUtil.Execute <MessagesRequest>(Constants.Url.MESSAGES, "post", oMessagesRequest);

            lst =
                JsonConvert.DeserializeObject <List <MessagesResponse> >(JsonConvert.SerializeObject(oReply.data));

            lst = lst.OrderBy(d => d.DateCreated).ToList();

            ViewBag.idRoom = id;

            return(View(lst));
        }
        public Reply List([FromBody] SecurityRequest model)
        {
            Reply oR = new UtilitiesChat.Models.WS.Reply();

            oR.result = 0;
            if (!VerifyToken(model))
            {
                oR.message = "Método no permitido";
                return(oR);
            }

            using (ChatDBEntities db = new ChatDBEntities())
            {
                List <ListRoomsResponce> lstRoomsResponce = (from d in db.room
                                                             where d.idState == 1
                                                             orderby d.name
                                                             select new ListRoomsResponce {
                    Name = d.name,
                    Description = d.description,
                    Id = d.id
                }).ToList();
                oR.data = lstRoomsResponce;
            }
            oR.result = 1;

            return(oR);
        }
Beispiel #4
0
        public ActionResult Register(ChatWeb.Models.ViewModels.RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Models.Request.User oUser = new Models.Request.User();
            oUser.Name     = model.Name;
            oUser.City     = model.City;
            oUser.Email    = model.Email;
            oUser.Password = model.Password;

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply = oRequestUtil.Execute <Models.Request.User>(Constants.Url.REGISTER, "Post", oUser);

            return(View());
        }
Beispiel #5
0
        // GET: Lobby
        public ActionResult Index()
        {
            GetSession();
            List <ListRoomResponse> lst = new List <ListRoomResponse>();
            SecurityRequest         oSecurityRequest = new SecurityRequest();

            oSecurityRequest.AccessToken = oUserSession.AccessToken;

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply =
                oRequestUtil.Execute <SecurityRequest>(Constants.Url.ROOMS, "Post", oSecurityRequest);

            lst =
                JsonConvert.DeserializeObject <List <ListRoomResponse> >(JsonConvert.SerializeObject(oReply.data));


            return(View(lst));
        }