Ejemplo n.º 1
0
        public async Task <IActionResult> ChangeCallMeStatus(string id, CallMeStatus callMeStatus)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest("Incorrect id"));
            }

            var callMe = await _callMeRepository.GetByIdAsync(id);

            if (callMe == null)
            {
                return(BadRequest("Call me don't exist or incorrect id"));
            }

            if (callMe.CallMeStatus == callMeStatus)
            {
                return(BadRequest($"Call me allready have status {callMe.CallMeStatus.ToString()}"));
            }

            callMe.CallMeStatus = callMeStatus;

            var updateRes = await _callMeRepository.UpdateAsync(callMe);

            if (updateRes >= 1)
            {
                return(Ok(_mapper.Map <CallMeDto>(callMe)));
            }

            return(BadRequest("Can't update call me"));
        }
Ejemplo n.º 2
0
        public IActionResult GetCallMe(CallMeStatus status, int pageNumber = 1, int pageSize = 16)
        {
            var callMeList = _callMeRepository
                             .Table
                             .Where(x => x.CallMeStatus == status);

            var callMePagination = new Paginator <CallMeDto>
            {
                Data       = _mapper.Map <IEnumerable <CallMeDto> >(callMeList).Page(pageNumber, pageSize),
                TotalCount = callMeList.Count(),
                PageSize   = pageSize,
                PageNumber = pageNumber
            };

            return(this.JsonResult(callMePagination));
        }