public async Task <ActionResult <Event> > Post([FromBody] Event events)
        {
            var findPromoteur = await _context.Promoteurs.FindAsync(events.PromoteurId);

            var findType = await _context.TypeEvents.FindAsync(events.TypeId);

            if (findPromoteur == null || findType == null)
            {
                return(NotFound("Le promoteur et le type n'existe pas"));
            }

            var EventExist = from e in _context.Events
                             where e.Nom == events.Nom
                             select new { e.Id, e.Nom };

            if (EventExist.Count() > 0)
            {
                return(Conflict("Cet évenement exsite déjà"));
            }
            events.CodeEvent = MyFunctions.GenererCodeEvent(_context.Events);
            events.Statut    = "A venir";
            events.Heure     = DateTime.Parse(events.Heure.ToLongTimeString());
            await _context.Events.AddAsync(events);

            await _context.SaveChangesAsync();

            return(Ok(events));
        }
示例#2
0
        public async Task <ActionResult <User> > Post([FromBody] User user)
        {
            var verifuser = from u in _context.Users
                            where u.Contact == user.Contact || u.Mail == user.Mail
                            select new { u.Id, u.Nom, u.Contact, u.Mail };

            if (verifuser.Count() > 0)
            {
                return(Conflict("L'utilisateur existe déja"));
            }

            await _context.Users.AddAsync(user);

            await _context.SaveChangesAsync();

            return(Ok(user));
        }
示例#3
0
        public async Task <ActionResult <TypeEvent> > Post([FromBody] TypeEvent typeEvent)
        {
            var TypeExist = from t in _context.TypeEvents
                            where t.Libelle == typeEvent.Libelle
                            select new { t.Id, t.Libelle };

            if (TypeExist.Count() > 0)
            {
                return(Conflict("Le libelle existe déja !"));
            }

            await _context.TypeEvents.AddAsync(typeEvent);

            await _context.SaveChangesAsync();

            return(Ok(typeEvent));
        }
        public async Task <ActionResult <Ticket> > Post([FromBody] Ticket ticket)
        {
            var verifEvent = from e in _context.Events
                             where e.Id == ticket.EventId
                             select new { e.Id, e.Nom };

            if (verifEvent.Count() == 0)
            {
                return(NotFound("L'évenement n'existe pas"));
            }

            await _context.Tickets.AddAsync(ticket);

            await _context.SaveChangesAsync();

            return(Ok(ticket));
        }
示例#5
0
        public async Task <ActionResult <Promoteur> > Post([FromBody] Promoteur promoteur)
        {
            var promoteurExist = from p in _context.Promoteurs
                                 where p.Contact == promoteur.Contact || p.Mail == promoteur.Mail
                                 select new { p.Id, p.Nom, p.Contact, p.Mail, p.Photo };

            if (promoteurExist.Count() > 0)
            {
                return(Conflict("Les informations existent déja !"));
            }

            await _context.Promoteurs.AddAsync(promoteur);

            await _context.SaveChangesAsync();

            return(Ok(promoteur));
        }
示例#6
0
        public async Task <ActionResult <UserTicket> > Post([FromBody] UserTicket achat)
        {
            var findTicket = await _context.Tickets.FindAsync(achat.TicketId);

            var findUser = await _context.Users.FindAsync(achat.UserId);

            if (findTicket == null || findUser == null)
            {
                return(NotFound("Le client et le ticket n'existe pas"));
            }

            achat.CodeQr = MyFunctions.GenererCodeQr(_context.UsersTickets);

            await _context.UsersTickets.AddAsync(achat);

            await _context.SaveChangesAsync();

            var Lastachat = from a in _context.UsersTickets
                            join t in _context.Tickets on a.TicketId equals t.Id
                            join u in _context.Users on a.UserId equals u.Id
                            where a.Id == achat.Id
                            select new
            {
                a.Id,
                a.UserId,
                a.TicketId,
                u.Nom,
                u.Contact,
                u.Mail,
                t.Montant,
                t.Type,
                a.CodeQr,
                a.CreatedAt
            };

            return(Ok(Lastachat));
        }