Пример #1
0
        public virtual void DeleteNumber(string phoneId = "")
        {
            var number = VoipDbContext.VoipNumbers.Where(r => r.Id == phoneId && r.TenantId == TenantID).FirstOrDefault();

            VoipDbContext.VoipNumbers.Remove(number);
            VoipDbContext.SaveChanges();
        }
Пример #2
0
        public virtual VoipPhone SaveOrUpdateNumber(VoipPhone phone)
        {
            if (!string.IsNullOrEmpty(phone.Number))
            {
                phone.Number = phone.Number.TrimStart('+');
            }

            var voipNumber = new VoipNumber
            {
                Id       = phone.Id,
                Number   = phone.Number,
                Alias    = phone.Alias,
                Settings = phone.Settings.ToString(),
                TenantId = TenantID
            };

            VoipDbContext.VoipNumbers.Add(voipNumber);
            VoipDbContext.SaveChanges();

            return(phone);
        }
Пример #3
0
 protected AbstractDao(DbContextManager <VoipDbContext> dbOptions, TenantManager tenantManager)
 {
     VoipDbContext = dbOptions.Get(dbid);
     TenantID      = tenantManager.GetCurrentTenant().TenantId;
 }
Пример #4
0
        public VoipCall SaveOrUpdateCall(VoipCall call)
        {
            var voipCall = new DbVoipCall
            {
                TenantId   = TenantID,
                Id         = call.Id,
                NumberFrom = call.From,
                NumberTo   = call.To,
                ContactId  = call.ContactId
            };

            if (!string.IsNullOrEmpty(call.ParentID))
            {
                voipCall.ParentCallId = call.ParentID;
            }

            if (call.Status.HasValue)
            {
                voipCall.Status = (int)call.Status.Value;
            }

            if (!call.AnsweredBy.Equals(Guid.Empty))
            {
                voipCall.AnsweredBy = call.AnsweredBy;
            }

            if (call.DialDate == DateTime.MinValue)
            {
                call.DialDate = DateTime.UtcNow;
            }

            voipCall.DialDate = TenantUtil.DateTimeToUtc(call.DialDate);

            if (call.DialDuration > 0)
            {
                voipCall.DialDuration = call.DialDuration;
            }

            if (call.Price > decimal.Zero)
            {
                voipCall.Price = call.Price;
            }

            if (call.VoipRecord != null)
            {
                if (!string.IsNullOrEmpty(call.VoipRecord.Id))
                {
                    voipCall.RecordSid = call.VoipRecord.Id;
                }

                if (!string.IsNullOrEmpty(call.VoipRecord.Uri))
                {
                    voipCall.RecordUrl = call.VoipRecord.Uri;
                }

                if (call.VoipRecord.Duration != 0)
                {
                    voipCall.RecordDuration = call.VoipRecord.Duration;
                }

                if (call.VoipRecord.Price != default)
                {
                    voipCall.RecordPrice = call.VoipRecord.Price;
                }
            }

            VoipDbContext.VoipCalls.Add(voipCall);
            VoipDbContext.SaveChanges();

            return(call);
        }
Пример #5
0
 protected AbstractDao(DbContextManager <VoipDbContext> dbOptions, int tenantID)
 {
     VoipDbContext = dbOptions.Get(dbid);
     TenantID      = tenantID;
 }