示例#1
0
        public void MassCreateComputers()
        {
            var fakeComputers = new List <ComputerViewModel>();

            for (int i = 1; i < 6; i++)
            {
                var computer = new ComputerViewModel()
                {
                    ComputerCode        = $"CCODE{i}",
                    ComputerName        = $"ComputerName {i}",
                    ComputerDescription = $"ComputerDesription {i}",
                    ComputerTypeId      = i,
                    DeparmentTypeId     = i,
                    ProducerTypeId      = i,
                    IsBusyNow           = false,
                    Status = true
                };
                fakeComputers.Add(computer);
            }

            foreach (var computerViewModel in fakeComputers)
            {
                Model.Models.Computer newComputer = new Model.Models.Computer();
                newComputer.UpdateComputer(computerViewModel);

                _computerService.Add(newComputer);
                _computerService.Save();
            }
        }
示例#2
0
        public HttpResponseMessage Post(HttpRequestMessage request, ComputerViewModel computerVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage errorResponse;
                if (AddUpdateComputerValidation(request, computerVm, out errorResponse))
                {
                    return errorResponse;
                }

                var newComputer = new Model.Models.Computer();
                newComputer.UpdateComputer(computerVm);

                var computer = _computerService.Add(newComputer);
                _computerService.Save();

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