public async Task <IActionResult> Profile()
        {
            string[] breadcrumb = { "Usuário", "Perfil" };
            ViewData["breadcrumb"] = breadcrumb;

            if (ViewData["success"] != null)
            {
                ViewData["success"] = ViewData["success"];
            }

            JsonDefaultResponse <ProfileViewModel> profile = new JsonDefaultResponse <ProfileViewModel>();

            try
            {
                profile = await Http.Get <ProfileViewModel>("user/GetProfileByUserId");
            }
            catch (Exception ex)
            {
            }

            if (profile.Payload == null)
            {
                profile.Payload      = new ProfileViewModel();
                ViewData["favoreds"] = profile.Message;
            }

            return(View(new ProfileViewData(UserLogged, profile.Payload)));
        }
        public async Task <IActionResult> Favoreds()
        {
            string[] breadcrumb = { "Favorecidos" };
            ViewData["breadcrumb"] = breadcrumb;

            if (TempData["success"] != null)
            {
                ViewData["success"] = ViewData["success"];
            }

            var favoreds = new JsonDefaultResponse <List <FavoredViewModel> >();

            try
            {
                favoreds = await Http.Get <List <FavoredViewModel> >("Favored/ByUserId");
            }
            catch (Exception ex)
            {
                TempData["error"] = ex.Message;
                return(Index());
            }

            if (favoreds.Payload == null)
            {
                favoreds.Payload     = new List <FavoredViewModel>();
                TempData["favoreds"] = favoreds.Message;
            }

            return(View(new FavoredViewData(UserLogged, favoreds.Payload)));
        }
Beispiel #3
0
        private static Task <TResponse> Errors(IEnumerable <ValidationFailure> failures)
        {
            var response = new JsonDefaultResponse
            {
                Success = false,
                Errors  = failures.Select(f => f.ErrorMessage).ToList(),
                Message = "Houveram um ou mais erros ao tentar realizar sua solicitação. Por favor, revise os valores enviados e tente novamente"
            };

            return(Task.FromResult(response as TResponse));
        }
        public async Task <IActionResult> Incomings()
        {
            string[] breadcrumb = { "rendas" };

            ViewData["breadcrumb"] = breadcrumb;

            JsonDefaultResponse <List <IncomingViewModel> > incomings = new JsonDefaultResponse <List <IncomingViewModel> >();

            try
            {
                incomings = await Http.Get <List <IncomingViewModel> >("incomings");
            }
            catch
            {
            }

            if (incomings.Payload == null)
            {
                incomings.Payload     = new List <IncomingViewModel>();
                ViewData["incomings"] = incomings.Message;
            }

            return(View(new IncomingViewData(UserLogged, incomings.Payload)));
        }