Ejemplo n.º 1
0
        public IActionResult GetServiceInfo(string userId, string serviceTypeName)
        {
            var response = new ApiResponseModel();

            var userOffice = _userOfficeRepository.GetSingle(x => x.UserId.Equals(userId));

            if (userOffice == null)
            {
                return(NotFound(response));
            }

            if (string.IsNullOrEmpty(serviceTypeName))
            {
                var services = _userOfficeManager.GetUserServices(userOffice);

                var mapped = new List <ServiceInfoResponseModel>();
                foreach (var s in services)
                {
                    mapped.Add(_mapper.Map <ServiceInfoResponseModel>(s));
                }
                response.Data.Add(nameof(services), mapped);

                return(Ok(response));
            }

            var service = _userOfficeManager.GetUserService(userOffice, serviceTypeName);

            response.Data.Add(nameof(service), _mapper.Map <ServiceInfoResponseModel>(service));

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public IActionResult EditServiceData([FromBody] EditUserServiceRequestModel model)
        {
            var response = new ApiResponseModel();

            UserService service = _userOfficeManager.GetUserService(UserOffice, model.ServiceTypeName);

            if (service == null)
            {
                return(NotFound(response));
            }
            bool status = _userOfficeManager.EditUserServiceData(UserOffice, model.ServiceTypeName, model.Data);

            if (status)
            {
                response.Message = "The service data has been edited";
                return(Ok(response));
            }
            response.Data.Add(nameof(status), status);
            response.Message = "Unable to edit service data";
            return(BadRequest(response));
        }