Esempio n. 1
0
        public async Task <CallsDto> UpdateCall(CallsDto call)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (call != null)
                    {
                        CallsEntity entity = call.ToModel();
                        entity.CallId = call.CallId;
                        db.Calls.Attach(entity);
                        foreach (var propName in db.Entry(entity).CurrentValues.PropertyNames)
                        {
                            if (propName != "CallId")
                            {
                                db.Entry(entity).Property(propName).IsModified = true;
                            }
                        }
                        await db.SaveChangesAsync();

                        return(entity.ToDto());
                    }
                    return(null);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
Esempio n. 2
0
        public async Task <CallsDto> CreateCall(CallsDto call)
        {
            Task <CallsDto> callDto;

            lock (obj)
            {
                callDto = callManager.AddCallDto(call);
            }
            return(await callDto);
        }
Esempio n. 3
0
 public static CallsEntity ToModel(this CallsDto call)
 {
     return(new CallsEntity()
     {
         CallId = call.CallId,
         DestinationNumber = call.DestinationNumber,
         Duration = call.Duration,
         ExternalPrice = call.ExternalPrice,
         LineId = call.LineId,
         //Line = call.Line.ToModel()
     });
 }
Esempio n. 4
0
 public async Task CreateCommunication(CommunicationModel communication, bool isSms, double duration)
 {
     communication.Time   = DateTime.Now;
     communication.LineId = communication.Line.LineId;
     if (isSms)
     {
         SMSDto sms = ModelExtensions.ToSms(communication);
         if (sms != null)
         {
             await invoice.AddSMSAsync(sms);
         }
     }
     else
     {
         CallsDto call = ModelExtensions.ToCall(communication, duration);
         if (call != null)
         {
             await invoice.AddCallAsync(call);
         }
     }
 }
Esempio n. 5
0
        public async Task <CallsDto> CreateCall(CallsDto call)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (call != null)
                    {
                        CallsEntity entity = call.ToModel();
                        db.Calls.Add(entity);
                        await db.SaveChangesAsync();

                        return(entity.ToDto());
                    }
                    return(null);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
Esempio n. 6
0
 public async Task <CallsDto> AddCall(CallsDto call)
 {
     return(await _manager.CreateCall(call));
 }
Esempio n. 7
0
 public async Task <CallsDto> AddCallDto(CallsDto dto)
 {
     return(await GetContainer().Resolve <ICallsRepository>().CreateCall(dto));
 }