Ejemplo n.º 1
0
        public int GetStepsForChallenge(int idChallenge)
        {
            var challenge = _retoRepository.GetById(idChallenge);

            return(_workContextService
                   .GetAuthenticatedUser()
                   .User
                   .LogEjercicios.Where(x => challenge.FechaInicio <= x.Fecha &&
                                        challenge.FechaFin >= x.Fecha)
                   .Sum(x => x.Conteo));
        }
Ejemplo n.º 2
0
        public ActionResult Challenges()
        {
            var userContext = _workContextService.GetAuthenticatedUser();
            var model       = new ChallengeModel();

            foreach (var reto in _retoService.GetChallengesWithUserRelated(userContext.User.Id))
            {
                model.DetailChallenges.Add(new DetailChallenge {
                    Name = reto.Name, Goal = reto.Meta, MyProgress = _retoService.GetStepsForChallenge(reto.Id)
                });
            }

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult FileUpload(HttpPostedFileBase file)
        {
            if (file != null)
            {
                var userContext = _workContext.GetAuthenticatedUser();
                // save the image path path to the database or you can send image
                // directly to database
                // in-case if you want to store byte[] ie. for DB
                byte[] array = null;
                using (MemoryStream ms = new MemoryStream())
                {
                    file.InputStream.CopyTo(ms);
                    array = ms.GetBuffer();
                }

                //var elm=_userRepository.GetById(user.Id);
                Picture p = new Picture();
                p.Bytes    = array;
                p.MimeType = file.ContentType;
                p.FileName = file.FileName;
                userContext.User.Avatar = p;

                //_userRepository.Update(elm);
                _userService.Update(userContext.User);
                _media.SavePictureInFile(p.Id, p.Bytes, p.MimeType);
            }
            // after successfully uploading redirect the user
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 4
0
        public ActionResult LogOff()
        {
            //WebSecurity.Logout();
            //return RedirectToAction("Index", "Home");
            var userContext = _workContext.GetAuthenticatedUser();

            _memoryCache.DeleteCache(userContext.User.UserName);
            FormsAuthentication.SignOut();
            Session.Abandon();

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 5
0
        public ActionResult NavBar()
        {
            var         userContext = _workContext.GetAuthenticatedUser();
            NavbarModel model       = new NavbarModel();

            PrepareLeagueModel(model, userContext);
            PrepareUserDataModel(model, userContext.User);

            return(View(model));
        }