Beispiel #1
0
        ViewModels.Garage IGaragesService.Add(BindingModels.Garage garageBindingModel)
        {
            if (garageBindingModel == null)
            {
                throw new ArgumentNullException(nameof(garageBindingModel));
            }

            var garageEntity = AutoMapper.Mapper.Map <Entities.Garage>(garageBindingModel);
            var addedGarage  = _unitOfWork.RepositoryFor <Entities.Garage>().Insert(garageEntity);

            _unitOfWork.SaveChanges();

            return(AutoMapper.Mapper.Map <ViewModels.Garage>(addedGarage));
        }
        public IActionResult Put([FromQuery] Guid id, [FromBody] BindingModels.Garage garageBindingModel)
        {
            if (id != garageBindingModel.Id)
            {
                return(BadRequest("Garage ID is not same."));
            }

            bool result = _garagesService.Update(garageBindingModel);

            if (result)
            {
                return(Ok());
            }
            return(NotFound());
        }
Beispiel #3
0
        bool IGaragesService.Update(BindingModels.Garage garageBindingModel)
        {
            if (garageBindingModel == null)
            {
                throw new ArgumentNullException(nameof(garageBindingModel));
            }

            var  garageEntity = AutoMapper.Mapper.Map <Entities.Garage>(garageBindingModel);
            bool result       = _unitOfWork.RepositoryFor <Entities.Garage>().Update(garageEntity);

            if (result)
            {
                _unitOfWork.SaveChanges();
            }

            return(result);
        }
Beispiel #4
0
 public bool Update(BindingModels.Garage garageBindingModel)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public ViewModels.Garage Add(BindingModels.Garage garageBindingModel)
 {
     throw new NotImplementedException();
 }
        public IActionResult Post([FromBody] BindingModels.Garage garageBindingModel)
        {
            var result = _garagesService.Add(garageBindingModel);

            return(Ok(result));
        }