Esempio n. 1
0
        public async Task <MessageLog> Send(Models.SendRequest request)
        {
            //log message
            var log = new Entity.MessageLog();

            log.To                  = request.To;
            log.From                = request.From;
            log.Body                = request.Message;
            log.ReferenceCode       = request.ReferenceCode;
            log.ThirdPartyServiceID = Guid.Parse("CE38FF59-A125-406B-81DB-FBF25BB06331");//TODO fix
            log = await SaveLog(log);

            request.MessageId = log.Id;

            //TODO actually have a queueing mechnamism
            await EnQueue(request);

            return(log);
        }
Esempio n. 2
0
        public async Task <Entity.MessageLog> SaveLog(Entity.MessageLog log)
        {
            using (var db = new Data.SMSDataModel())
            {
                if (log.Id == Guid.Empty)
                {
                    log.Id         = Guid.NewGuid();
                    log.CreateDate = DateTime.UtcNow;
                    db.MessageLogs.Add(log);
                }
                else
                {
                    db.MessageLogs.Attach(log);
                    db.Entry(log).State = EntityState.Modified;
                }

                await db.SaveChangesAsync();

                return(log);
            }
        }