public void MassCreateComputerUsingHistories()
        {
            var random = new Random();

            var listAppUser = AppUserManager.Users;
            var firstUser   = listAppUser.First();

            var fakeComputerUsingHistories = new List <ComputerUsingHistoryViewModel>();

            for (int i = 0; i < 10; i++)
            {
                var computerUsingHistory = new ComputerUsingHistoryViewModel()
                {
                    ComputerId = random.Next(1, 5),
                    UserId     = firstUser.Id,
                    Status     = true,
                    StartTime  = DateTime.Now,
                    EndTime    = DateTime.Now.AddHours(random.Next(2, 4))
                };
                fakeComputerUsingHistories.Add(computerUsingHistory);
            }

            foreach (var computerUsingHistoryViewModel in fakeComputerUsingHistories)
            {
                var newComputerUsingHistory = new ComputerUsingHistory();
                newComputerUsingHistory.UpdateComputerUsingHistory(computerUsingHistoryViewModel);

                _computerUsingHistoryService.Add(newComputerUsingHistory);
                _computerUsingHistoryService.Save();
            }
        }
        public HttpResponseMessage Post(HttpRequestMessage request, ComputerUsingHistoryViewModel computerTypeVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.Values.FirstOrDefault()?.Errors.FirstOrDefault()?.ErrorMessage);
                }
                else
                {
                    var newComputerUsingHistory = new ComputerUsingHistory();
                    newComputerUsingHistory.UpdateComputerUsingHistory(computerTypeVm);

                    var computerUsingHistory = _computerUsingHistoryService.Add(newComputerUsingHistory);
                    _computerUsingHistoryService.Save();

                    response = request.CreateResponse(HttpStatusCode.Created, computerUsingHistory);
                }
                return response;
            }));
        }