Example #1
0
        public ActionResult <string> Get(string message, string sender, string receiver, string email)
        {
            try
            {
                User lm = _iuser.Userdetails(email);
                int  g  = lm.Limit;
                Console.WriteLine(g);
                int limit = _control.smscount(email);
                Console.WriteLine(limit);

                if (g != limit)
                {
                    OTPMessage otpmessage = new OTPMessage {
                        Message = message, Sender = sender, api = email, Receiver = receiver
                    };
                    _message.Add(otpmessage);

                    return("Message was added Successfully");
                }
                else
                {
                    return("Your limit was reached... Please renew");
                }
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
        public OTPMessage Add(OTPMessage message)
        {
            context.GetOTPMessages.Add(message);
            var e = context.getAPI.First(a => a.ekey == message.api);

            e.smscounter = e.smscounter + 1;
            context.SaveChanges();
            return(message);
        }
        public OTPMessage Update(OTPMessage content)
        {
            var content2 = context.GetOTPMessages.Attach(content);

            // var content3 = context.getAPI.Attach(control);
            content2.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            // content3.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(content);
        }
        public OTPMessage Delete(string receiver)
        {
            OTPMessage message = context.GetOTPMessages.FirstOrDefault(e => e.Receiver == receiver);

            if (message != null)
            {
                context.Remove(message);
                context.SaveChanges();
            }
            return(message);
        }
Example #5
0
        public ActionResult <OTPMessage> getmess(string receiver)
        {
            OTPMessage otp = null;

            do
            {
                otp = getmessage(receiver);
                if (otp != null)
                {
                    deletemsg(receiver, 5000);
                    return(otp);
                }
            } while (true);
        }
Example #6
0
        public ActionResult <string> update(string message, string receiver, string sender, string email)
        {
            string em    = email;
            int    g     = _iuser.Userdetails(email).Limit;
            int    limit = _control.smscount(email);

            if (g != limit)
            {
                OTPMessage otpmessage = new OTPMessage {
                    Message = message, Sender = sender, api = email, Receiver = receiver
                };
                apikeycontrol control = new apikeycontrol {
                    ekey = em, smscounter = limit + 1
                };
                // _control.Update(control);
                _message.Update(otpmessage);
                return("Message was updated Successfully");
            }
            else
            {
                return("Your limit was reached... Please renew");
            }
        }