Ejemplo n.º 1
0
        public void PutCompanyCarTest()
        {
            var model = new CompanyCarUpdateViewModel()
            {
                Id = 3, Name = "Hyundai", Category = 2
            };
            var result = _companyCarController.Put(model) as OkNegotiatedContentResult <CompanyCar>;

            Assert.IsNotNull(result.Content);
            Assert.AreEqual(result.Content.Name, "Hyundai");
        }
Ejemplo n.º 2
0
        public IHttpActionResult Put(CompanyCarUpdateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var CompanyCar = _companyCarRepository.GetAll(a => a.Id == model.Id).FirstOrDefault();

            if (CompanyCar == null)
            {
                return(NotFound());
            }

            CompanyCar.Name       = model.Name;
            CompanyCar.CategoryId = model.Category;

            var result = _companyCarRepository.Update(CompanyCar);

            return(Ok(result));
        }