public async Task <IHttpActionResult> GetById(int id) { CarCateDTO CarCate = await CarCateService.GetAll().Where(x => x.Id == id && !x.Deleted).ProjectTo <CarCateDTO>().FirstOrDefaultAsync(); if (CarCate == null) { return(NotFound()); } return(Ok(CarCate)); }
public async Task <IHttpActionResult> Update([FromBody] CarCateDTO CarCateDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = await CarCateService.FindOneAsync(CarCateDto.Id); entity = CarCateDto.ToEntity(entity); entity.LastUserId = User.Identity.GetUserId(); entity.LastTime = DateTime.Now; await CarCateService.UpdateAsync(entity); return(Ok(entity.ToModel())); }
public static CarCate ToEntity(this CarCateDTO dto, CarCate entity) { return(Mapper.Map(dto, entity)); }
public static CarCate ToEntity(this CarCateDTO dto) { return(Mapper.Map <CarCateDTO, CarCate>(dto)); }