public async Task <ActionResult> GetRentalByIdAsync(int id)
        {
            BuildUserPrincipal();
            var rental = await _rentalService.GetRentalAsync(id);

            return(Json(JsonResultData.Success(rental)));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> UpdateRobotTypeAsync(int id, [FromBody] UpdateRobotTypeDto robotType)
        {
            robotType.Id = id;
            var type = await _robotTypeService.UpdateRobotTypeAsync(robotType);

            return(Json(JsonResultData.Success(type)));
        }
Exemplo n.º 3
0
        public async Task <JsonResultData> Register([FromBody] UserRegistrationModel data)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    UserName    = data.Email,
                    Email       = data.Email,
                    FirstName   = data.FirstName,
                    LastName    = data.LastName,
                    PhoneNumber = data.Phone,
                    Interests   = data.Interests,
                    Role        = Role.User
                };

                var result = await _userManager.CreateAsync(user, data.Password);

                if (result.Succeeded)
                {
                    return(JsonResultData.Success());
                }
            }

            return(JsonResultData.Error("ApiUser already exists."));
        }
        public async Task <ActionResult> UpdateRobotModelAsync(int id, [FromBody] UpdateRobotModelDto robotModel)
        {
            robotModel.Id = id;
            var model = await _robotModelService.UpdateRobotModelAsync(robotModel);

            return(Json(JsonResultData.Success(model)));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> UpdateRobotAsync(int id, [FromBody] UpdateRobotDto robot)
        {
            robot.Id = id;
            var result = await _robotService.UpdateRobotAsync(robot);

            return(Json(JsonResultData.Success(result)));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Register([FromBody] UserRegistrationDto data)
        {
            if (ModelState.IsValid)
            {
                var user = new Domain.Users.User
                {
                    UserName        = data.Email,
                    Email           = data.Email,
                    FirstName       = data.FirstName,
                    LastName        = data.LastName,
                    FacilityId      = data.FacilityId,
                    DoctorId        = data.DoctorId,
                    DateOfBirthsday = data.DateOfBirthsday,
                    Role            = data.Role
                };

                var result = await _userManager.CreateAsync(user, data.Password);

                if (result.Succeeded)
                {
                    return(Json(JsonResultData.Success()));
                }
            }

            return(Json(JsonResultData.Error("User already exists.")));
        }
Exemplo n.º 7
0
        public IActionResult GetDrugsByTerm(string term)
        {
            var userModel = User.GetUserModel();
            var items     = _drugService.GetDrugsByTerm(term ?? string.Empty);

            return(Json(JsonResultData.Success(items)));
        }
        public async Task <ActionResult> UpdateRobotCompanyAsync(int id, [FromBody] UpdateRobotCompanyDto robotCompany)
        {
            robotCompany.Id = id;
            var company = await _robotCompanyService.UpdateRobotCompanyAsync(robotCompany);

            return(Json(JsonResultData.Success(company)));
        }
Exemplo n.º 9
0
        public IActionResult AddRent([FromBody] AddRentDto rent)
        {
            rent.Status = Domain.Rents.RentStatus.Pending;
            var result = _rentService.AddRent(rent);

            return(Json(JsonResultData.Success(result)));
        }
Exemplo n.º 10
0
        public IActionResult GetDepartmentsByTerm(string term)
        {
            var userModel  = User.GetUserModel();
            var facilities = _departmentService.GetDepartmentsByTerm(userModel.FacilityId.Value, term ?? string.Empty);

            return(Json(JsonResultData.Success(facilities)));
        }
        public IActionResult GetManipulationsByTerm(string term)
        {
            var userModel = User.GetUserModel();
            var items     = _manipulationService.GetManipulationsByTerm(userModel.FacilityId.Value, term ?? string.Empty);

            return(Json(JsonResultData.Success(items)));
        }
Exemplo n.º 12
0
        public async Task <ActionResult> DeleteFavoriteUserRobotAsync(int id)
        {
            BuildUserPrincipal();

            await _robotService.DeleteFavoriteUserRobotAsync(ApiUser.Id, id);

            return(StatusCode((int)HttpStatusCode.Created, Json(JsonResultData.Success())));
        }
Exemplo n.º 13
0
        public IActionResult GetMyContacts(string userId)
        {
            var contacts = _residentContactService.GetResidentContactsByParams(new ResidentContactsFilterParams
            {
                UserId = userId
            });

            return(Json(JsonResultData.Success(contacts)));
        }
        public IActionResult AddResidentManipulation([FromBody] AddResidentManipulationDto data)
        {
            var userModel = User.GetUserModel();

            data.DoctorId = userModel.DoctorId.Value;

            _residentManipulationService.AddResidentManipulation(data);
            return(Json(JsonResultData.Success()));
        }
        public async Task <ActionResult> CreateRentalAsync([FromBody] CreateRentalDto rental)
        {
            BuildUserPrincipal();
            rental.UserId = ApiUser.Id;

            var result = await _rentalService.CreateRentalAsync(rental);

            return(StatusCode((int)HttpStatusCode.Created, Json(JsonResultData.Success(result))));
        }
        public ActionResult NullEntityCheckResponse <TEntity>(TEntity entity)
        {
            if (entity == null)
            {
                return(NotFound());
            }

            return(Json(JsonResultData.Success(entity)));
        }
Exemplo n.º 17
0
        public async Task <ActionResult> GetMostValuableRobotsAsync([FromBody] RobotMostValuableFilterParamsDto filterParams)
        {
            BuildUserPrincipal();

            filterParams.UserId = ApiUser.Id;

            var robots = await _robotService.GetMostValuableRobotByFilterParamsAsync(filterParams);

            return(Json(JsonResultData.Success(robots.Where(t => t.Id != filterParams.CurrentRobotId))));
        }
Exemplo n.º 18
0
        public async Task <ActionResult> GetDashboardRobotsAsync([FromBody] RobotFilterParamsDto filterParams)
        {
            BuildUserPrincipal();

            filterParams.UserId = ApiUser.Id;

            var robots = await _robotService.GetDashboardRobotByFilterParamsAsync(filterParams);

            return(Json(JsonResultData.Success(robots)));
        }
Exemplo n.º 19
0
        public async Task <ActionResult> CreateRobotAsync([FromBody] CreateRobotDto robot)
        {
            BuildUserPrincipal();
            robot.UserId = ApiUser.Id;

            var result = await _robotService.CreateRobotAsync(robot);

            _client.Enqueue(() => _robotService.SendNotificationByUserInterestsAsync(CancellationToken.None));

            return(StatusCode((int)HttpStatusCode.Created, Json(JsonResultData.Success(result))));
        }
        public IActionResult GetResidents([FromBody] ResidentsFilterParams filterParams)
        {
            var userModel = User.GetUserModel();

            filterParams.FacilityId = userModel.FacilityId;
            filterParams.DoctorId   = userModel.DoctorId;

            var residents = _residentService.GetResidentsByParams(filterParams);

            return(Json(JsonResultData.Success(residents)));
        }
        public async Task <ActionResult> CreateRentalMessageAsync([FromBody] CreateRentalMessageDto message)
        {
            BuildUserPrincipal();

            message.UserId = ApiUser.Id;

            var result = await _rentalMessageService.CreateRentalMessageAsync(message);

            _backgroundJobClient.Enqueue(() => _rentalMessageService.SendEmailAsync(message, CancellationToken.None));

            return(StatusCode((int)HttpStatusCode.Created, Json(JsonResultData.Success(result))));
        }
Exemplo n.º 22
0
        public async Task <JsonResultData> UpdateUserAsync([FromBody] UpdateUserModel data)
        {
            var user = await _userManager.FindByIdAsync(data.Id);

            user.FirstName   = data.FirstName;
            user.LastName    = data.LastName;
            user.Interests   = data.Interests;
            user.PhoneNumber = data.PhoneNumber;

            await _userManager.UpdateAsync(user);

            return(JsonResultData.Success());
        }
        public IActionResult GetManipulations([FromBody] ManipulationsFilterParams filterParams)
        {
            UserDto user = User.GetUserModel();

            if (user.FacilityId.HasValue)
            {
                filterParams.FacilityId = user.FacilityId.Value;
            }

            var items = _manipulationService.GetManipulationsByParams(filterParams);

            return(Json(JsonResultData.Success(items)));
        }
Exemplo n.º 24
0
        public IActionResult GetDepartments([FromBody] DepartmentsFilterParams filterParams)
        {
            var userModel = User.GetUserModel();

            if (userModel.FacilityId.HasValue)
            {
                filterParams.FacilityId = userModel.FacilityId.Value;
            }

            var items = _departmentService.GetDepartmentsByParams(filterParams);

            return(Json(JsonResultData.Success(items)));
        }
        public async Task <ActionResult> GetRentalsAsync([FromQuery] RentalFilterParamsDto filterParams)
        {
            BuildUserPrincipal();

            if (ApiUser.Role == Role.User)
            {
                filterParams.UserId = ApiUser.Id;
            }

            var rentals = await _rentalService.GetRentalsByFilterParamsAsync(filterParams);

            return(Json(JsonResultData.Success(rentals)));
        }
        public IActionResult GetDoctors([FromBody] DoctorsFilterParams filterParams)
        {
            var userModel = User.GetUserModel();

            if (userModel.FacilityId.HasValue)
            {
                filterParams.FacilityId = userModel.FacilityId.Value;
            }

            var doctors = _doctorService.GetDoctorsByParams(filterParams);

            return(Json(JsonResultData.Success(doctors)));
        }
        public async Task <ActionResult> GetTopRobotCompaniesByRentsCountAsync(int?count)
        {
            var filterParams = new RobotPopularityFilterParamsDto
            {
                Type        = RobotPopularity.ByRentCount,
                CountToTake = count ?? 5
            };

            var companies = await _robotCompanyService.GetTopNPopularCompaniesAsync(filterParams);

            return(Json(JsonResultData.Success(companies.Where(t => t.CountOfRents > 0).Select(t => new PieChartModel
            {
                Name = t.Name,
                Value = t.CountOfRents
            }))));
        }
        public ActionResult ValidateAccessToEntity <TEntity>(string userId, TEntity entity)
        {
            if (entity == null)
            {
                return(NotFound());
            }

            if (ApiUser.Role == Role.Admin)
            {
                return(Json(JsonResultData.Success(entity)));
            }

            if (userId != ApiUser.Id)
            {
                return(Forbid());
            }

            return(Json(JsonResultData.Success(entity)));
        }
        public async Task <IActionResult> AddDoctor([FromBody] AddDoctorDto doctorDto)
        {
            int doctorId = _doctorService.AddDoctor(doctorDto);

            var user = new User
            {
                UserName   = doctorDto.Email,
                Email      = doctorDto.Email,
                FirstName  = doctorDto.FirstName,
                LastName   = doctorDto.LastName,
                FacilityId = doctorDto.FacilityId,
                DoctorId   = doctorId,
                Role       = Role.FacilityDoctor
            };

            var result = await _userManager.CreateAsync(user, doctorDto.Password);

            return(Json(JsonResultData.Success()));
        }
        public IActionResult GetResidentById(int id)
        {
            var resident = _residentService.GetResidentById(id);

            var residentObservations = _observationService.GetObservationsByParams(new ObservationParams
            {
                ResidentId = id
            });

            var residentModel = new ResidentDetailsModel
            {
                Resident      = resident,
                BloodPressure = residentObservations.Collection.FirstOrDefault(t => t.Type == Domain.Residents.ObservationType.BloodPressure),
                HeartRate     = residentObservations.Collection.FirstOrDefault(t => t.Type == Domain.Residents.ObservationType.HeartRate),
                Temperature   = residentObservations.Collection.FirstOrDefault(t => t.Type == Domain.Residents.ObservationType.Temperature)
            };

            return(Json(JsonResultData.Success(residentModel)));
        }