Exemplo n.º 1
0
        /// <summary>
        /// Установить статусы текущего принятого вызова
        /// </summary>
        public void SetCurrentCallStates(CallDto activeCall)
        {
            if (activeCall == null || activeCall.Status != CallStatus.Start)
            {
                return;
            }

            CallId         = activeCall.Id;
            ConnectionMode = activeCall.ConnectionMode.ToString();

            if (activeCall.OnHold)
            {
                CurrentCallStates.Add(CallStatusDto.IsOnHold);
            }
            else
            {
                CurrentCallStates.Add(CallStatusDto.CallActive);
            }

            if (activeCall.IsMutedMicrophone)
            {
                CurrentCallStates.Add(CallStatusDto.IsMutedMicrophone);
            }

            if (activeCall.Isolated)
            {
                CurrentCallStates.Add(CallStatusDto.IsIsolated);
            }
        }
Exemplo n.º 2
0
        public async Task <CallDto> UpdateCall(int id, CallDto callDto)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (id != callDto.CallId)
                    {
                        return(null);
                    }
                    else
                    {
                        Call call = db.Calls.FirstOrDefault(c => c.CallId == id);
                        if (call == null)
                        {
                            return(null);
                        }
                        else
                        {
                            call = callDto.ToModel();
                            db.Entry(call).State = System.Data.Entity.EntityState.Modified;
                            await db.SaveChangesAsync();

                            return(call.ToDto());
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
Exemplo n.º 3
0
        public async Task <CallDto> CreateCall(CallDto callDto)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (callDto == null)
                    {
                        return(null);
                    }
                    else
                    {
                        db.Calls.Add(callDto.ToModel());
                        await db.SaveChangesAsync();

                        return(callDto);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
Exemplo n.º 4
0
 public static Call Map(CallDto dto)
 {
     return(new Call
     {
         NumberOfMinutes = dto.NumberOfMinutes,
         FeePerMinute = dto.FeePerMinute,
     });
 }
Exemplo n.º 5
0
        public async Task <CallDto> CreateCall(CallDto call)
        {
            Task <CallDto> callDto;

            lock (_obj)
            {
                callDto = _callProvider.AddCall(call);
            }
            return(await callDto);
        }
Exemplo n.º 6
0
 private BaseCall MapCallDtoToCallVaccine(CallDto callVaccine)
 {
     return(new CallVaccine
     {
         Address = callVaccine.Address,
         Animal = _animalsRepository.GetById(callVaccine.AnimalId),
         Date = callVaccine.Date,
         Id = callVaccine.Id,
         Vaccine = _vaccinesRepository.GetById(callVaccine.WorkId)
     });
 }
Exemplo n.º 7
0
 private BaseCall MapCallDtoToCallTreatment(CallDto callDto)
 {
     return(new CallTreatment
     {
         Address = callDto.Address,
         Animal = _animalsRepository.GetById(callDto.AnimalId),
         Date = callDto.Date,
         Id = callDto.Id,
         Treatment = _treatmentsRepository.GetById(callDto.WorkId)
     });
 }
Exemplo n.º 8
0
 public static CallVm MapCallDtoToCallVm(CallDto callDto)
 {
     return(new CallVm
     {
         Address = callDto.Address,
         BreedName = callDto.BreedName,
         Date = callDto.Date,
         Id = callDto.Id,
         WorkName = callDto.WorkName,
         WorkType = callDto.WorkType
     });
 }
Exemplo n.º 9
0
 public static Call ToModel(this CallDto callDto)
 {
     if (callDto == null)
     {
         return(null);
     }
     return(new Call
     {
         CallId = callDto.CallId,
         DestinationNumber = callDto.DestinationNumber,
         Duration = callDto.Duration,
         ExternalPrice = callDto.ExternalPrice,
         LineId = callDto.LineId,
         Line = callDto.Line.ToModel()
     });
 }
Exemplo n.º 10
0
        private static CallDto MapBaseCallToDto(BaseCall call)
        {
            var callsDto = new CallDto
            {
                Address   = call.Address,
                BreedName = call.Animal.Breed.Name,
                Date      = call.Date,
                Id        = call.Id,
                WorkType  = call.WorkType.Name
            };

            if (call is CallTreatment callTreatment)
            {
                callsDto.WorkName = callTreatment.Treatment.Name;
            }
            else if (call is CallVaccine callVaccine)
            {
                callsDto.WorkName = callVaccine.Vaccine.Name;
            }

            return(callsDto);
        }
Exemplo n.º 11
0
 public async Task <CallDto> UpdateCall(int callId, CallDto callDto)
 {
     return(await GetContainer().Resolve <ICallRepository>().UpdateCall(callId, callDto));
 }
Exemplo n.º 12
0
 public async Task <CallDto> AddCall(CallDto dto)
 {
     return(await GetContainer().Resolve <ICallRepository>().CreateCall(dto));
 }
Exemplo n.º 13
0
 public ResponseDto CreateVaccineCall([FromBody] CallDto callVaccineDto)
 {
     _callsRepository.CreateCall(MapCallDtoToCallVaccine(callVaccineDto));
     return(new ResponseDto());
 }
Exemplo n.º 14
0
 public ResponseDto CreateTreatmentCall([FromBody] CallDto callTreatmentDto)
 {
     _callsRepository.CreateCall(MapCallDtoToCallTreatment(callTreatmentDto));
     return(new ResponseDto());
 }
Exemplo n.º 15
0
 public static ResponseDto CreateTreatmentCall(CallDto callDto)
 {
     return(PostQuery(callDto, Constants.CREATE_TREATMENT_CALL));
 }
 public async Task <CallDto> AddCall(CallDto call)
 {
     return(await _invoiceProvider.CreateCall(call));
 }
Exemplo n.º 17
0
 public static ResponseDto CreateVaccineCall(CallDto callDto)
 {
     return(PostQuery(callDto, Constants.CREATE_VACCINE_CALL));
 }