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); } } }
public async Task <CallsDto> CreateCall(CallsDto call) { Task <CallsDto> callDto; lock (obj) { callDto = callManager.AddCallDto(call); } return(await callDto); }
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() }); }
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); } } }
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); } } }
public async Task <CallsDto> AddCall(CallsDto call) { return(await _manager.CreateCall(call)); }
public async Task <CallsDto> AddCallDto(CallsDto dto) { return(await GetContainer().Resolve <ICallsRepository>().CreateCall(dto)); }