コード例 #1
0
        private Models.Emprestimo retornarEmprestimo(int amigoId)
        {
            var usuarioId = getUsuarioId();
            List <Entities.Models.Emprestimo> emprestimos = _repository.Emprestimo.ObterTodos(usuarioId).ToList();
            List <Entities.Models.Jogo>       jogos       = _repository.Jogo.ObterTodos(usuarioId).ToList();
            var lstJogosEmprestados = new List <Models.JogoEmprestado>();

            foreach (var item in jogos)
            {
                bool emprestado = false;
                if (emprestimos.Any())
                {
                    var oEmprestimo = (from obj in emprestimos
                                       where obj.Amigo == amigoId && item.Id == obj.Jogo
                                       select obj).FirstOrDefault();
                    if (oEmprestimo != null)
                    {
                        emprestado = (oEmprestimo.Emprestado == 1);
                    }
                }
                var jogoEmprestado = new Models.JogoEmprestado(item, amigoId, emprestado);
                lstJogosEmprestados.Add(jogoEmprestado);
            }
            var Emprestimo = new Models.Emprestimo();

            Emprestimo.lstJogosEmprestados = lstJogosEmprestados;
            return(Emprestimo);
        }
コード例 #2
0
        public IActionResult GravarEmprestimo(Models.Emprestimo Emprestimo)
        {
            try
            {
                _repository.Emprestimo.Excluir(getUsuarioId());
                if (Emprestimo.lstJogosEmprestados.Any())
                {
                    foreach (var item in Emprestimo.lstJogosEmprestados)
                    {
                        var emprestimo = new Entities.Models.Emprestimo();
                        emprestimo.Amigo = item.geAmigoId;
                        if (item.emprestado)
                        {
                            emprestimo.Emprestado = 1;
                        }
                        else
                        {
                            emprestimo.Emprestado = 0;
                        }
                        emprestimo.Jogo    = item.getJogoId;
                        emprestimo.Usuario = getUsuarioId();
                        _repository.Emprestimo.CriarEmprestimo(emprestimo);
                    }
                }

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
 public IActionResult BuscarJogosEmprestado(Entities.Models.Amigo amigo)
 {
     Models.Emprestimo Emprestimo = retornarEmprestimo(amigo.Id);
     Emprestimo.lstAmigos = getAmigos(getUsuarioId());
     Emprestimo.Usuario   = getUsuarioId();
     ViewBag.Emprestimo   = Emprestimo;
     return(View());
 }
コード例 #4
0
        public IActionResult Devolver(int id)
        {
            string msg = new Models.Emprestimo().DevolverEmprestimo(id);

            return(Json(new
            {
                msg
            }));
        }
コード例 #5
0
 public void Put(int id, [FromBody] Models.Emprestimo value)
 {
 }
コード例 #6
0
 public void Post([FromBody] Models.Emprestimo value)
 {
 }