Exemple #1
0
        public async Task <IActionResult> ResponderPedidoCasamento(int id, bool aceitarPedido)
        {
            var pedidoCasamento = await _pedidoCasamentoService.GetById(id);

            if (pedidoCasamento == null)
            {
                return(NotFound());
            }

            if (pedidoCasamento.DataPedidoAceito.HasValue || pedidoCasamento.DataPedidoNegado.HasValue)
            {
                return(BadRequest(new { Success = false, Message = "Este pedido de casamento já foi respondido." }));
            }

            if (!aceitarPedido)
            {
                pedidoCasamento.DataPedidoNegado = DateTime.Now;
                await _pedidoCasamentoService.Update(pedidoCasamento);

                return(NoContent());
            }

            pedidoCasamento.DataPedidoAceito = DateTime.Now;
            await _pedidoCasamentoService.Update(pedidoCasamento);

            var casamento = new Casamento
            {
                PedidoCasamentoId = id
            };
            await _casamentoService.Add(casamento);

            return(Ok(new { Success = true, IdCasamento = casamento.Id }));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Casamento casamento = db.Casamento.Find(id);

            db.Casamento.Remove(casamento);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,noivo,noiva,data,email,solicitante,msg,telefone,aprovado")] Casamento casamento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(casamento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(casamento));
 }
        public ActionResult Create([Bind(Include = "id,noivo,noiva,data,email,solicitante,msg,telefone,aprovado")] Casamento casamento)
        {
            casamento.aprovado = false;

            if (ModelState.IsValid)
            {
                db.Casamento.Add(casamento);
                db.SaveChanges();
                return(RedirectToAction("Casamento", "Home"));
            }

            return(RedirectToAction("Casamento", "Home"));
        }
        // GET: Casamento/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Casamento casamento = db.Casamento.Find(id);

            if (casamento == null)
            {
                return(HttpNotFound());
            }
            return(View(casamento));
        }
        public ActionResult Aprova(int id)
        {
            Casamento casamento = db.Casamento.SingleOrDefault(c => c.id == id);

            casamento.aprovado = true;
            db.Evento.Add(new Evento()
            {
                nome = "Casamento " + casamento.noivo + " & " + casamento.noiva, dataHora = casamento.data, tipoEvento = db.TipoEvento.First().id, imagemEvento = db.Evento.First().imagemEvento
            });

            db.SaveChanges();



            return(RedirectToAction("Casamento", "Home"));
        }
Exemple #7
0
        private bool VerificaTestemunhaCasamento(Casamento casamento, int idUsuarioTestemunha)
        {
            if (casamento.UsuarioPrimeiraTestemunhaId.HasValue)
            {
                if (casamento.UsuarioPrimeiraTestemunhaId.Value == idUsuarioTestemunha)
                {
                    return(false);
                }
            }

            if (casamento.UsuarioSegundaTestemunhaId.HasValue)
            {
                if (casamento.UsuarioSegundaTestemunhaId.Value == idUsuarioTestemunha)
                {
                    return(false);
                }
            }

            return(true);
        }