Esempio n. 1
0
        public async Task <bool> NotBadComment(int id)
        {
            var comment = await _context.Comments.FindAsync(id);

            if (comment == null)
            {
                return(false);
            }

            comment.Status = "Aceptado";
            _context.Entry(comment).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <IActionResult> PutUserStrikes(int id, UserStrikes userStrikes)
        {
            if (id != userStrikes.IduserStrikes)
            {
                return(BadRequest());
            }

            _context.Entry(userStrikes).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserStrikesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> PutSchedule(int id, Schedule schedule)
        {
            if (id != schedule.Idschedule)
            {
                return(BadRequest());
            }

            _context.Entry(schedule).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScheduleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <string> AcceptRestaurant(int id)
        {
            var restaurant = await _context.Restaurant.FindAsync(id);

            if (restaurant == null)
            {
                return("Error. Intente de nuevo más tarde.");
            }

            restaurant.Password = GeneratePassword();
            _context.Entry(restaurant).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            await AddGeneralWaiter(restaurant.Idrestaurant);
            await SetPoicies(restaurant.Idrestaurant);
            await SendNewPassword(restaurant.Mail, restaurant.Password);

            return(restaurant.Password);
        }
Esempio n. 5
0
        public async Task <bool> LockMailSubscriptions(int id)
        {
            var mail = await _context.UserRestaurant
                       .Where(u => u.Iduser == id && u.MailSubscription == true)
                       .ToListAsync();

            foreach (var m in mail)
            {
                m.MailSubscription      = false;
                _context.Entry(m).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            return(true);
        }
Esempio n. 6
0
        public async Task <string> SendMail(string mail)
        {
            var client = _context.User.Where(c => c.Mail == mail).FirstOrDefault();

            if (client == null)
            {
                return("Error. El correo ingresado no tiene cuenta en MrPiatto.");
            }

            client.Password = GeneratePassword();
            _context.Entry(client).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            await SendNewPassword(client.Mail, client.Password);

            return("Ha sido enviado un correo con la nueva contraseña.");
        }
Esempio n. 7
0
        private async Task <bool> GenerateQRAsync(Reservation reservation)
        {
            var client  = new RestClient($"https://qrcode3.p.rapidapi.com/generateQR?fill_style=solid&inner_eye_style=circle&style=circle&outer_eye_style=circle&ec_level=M&format=png&size=800&text={reservation.Idreservation}");
            var request = new RestRequest(Method.GET);

            request.AddHeader("x-rapidapi-host", "qrcode3.p.rapidapi.com");
            request.AddHeader("x-rapidapi-key", "2226ad8917msh0d8f7e8e40c4b9fp19d487jsn5d51681b32fc");
            IRestResponse response = client.Execute(request);

            byte[] bitmap = response.RawBytes;

            Image image = Image.FromStream(new MemoryStream(bitmap));

            image.Save($@"{pathQRBase}\{reservation.Iduser}_{reservation.Idreservation}.png", ImageFormat.Png);

            reservation.Url = $"{pathServer}{reservation.Iduser}_{reservation.Idreservation}.png";
            _context.Entry(reservation).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(true);
        }