Exemplo n.º 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));
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 public bool Update(BindingModels.Garage garageBindingModel)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public ViewModels.Garage Add(BindingModels.Garage garageBindingModel)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
        public IActionResult Post([FromBody] BindingModels.Garage garageBindingModel)
        {
            var result = _garagesService.Add(garageBindingModel);

            return(Ok(result));
        }