public async Task <IHttpActionResult> GetById(int id) { ProductStorageQuantityDTO ProductStorageQuantity = await ProductStorageQuantityService.GetAll().Where(x => x.Id == id).ProjectTo <ProductStorageQuantityDTO>().FirstOrDefaultAsync(); if (ProductStorageQuantity == null) { return(NotFound()); } return(Ok(ProductStorageQuantity)); }
public async Task <IHttpActionResult> Create([FromBody] ProductStorageQuantityDTO ProductStorageQuantityDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = ProductStorageQuantityDto.ToEntity(); entity.CreateUserId = User.Identity.GetUserId(); entity.CreateTime = DateTime.Now; await ProductStorageQuantityService.InsertAsync(entity); return(Ok(entity.ToModel())); }
public static ProductStorageQuantity ToEntity(this ProductStorageQuantityDTO dto, ProductStorageQuantity entity) { return(Mapper.Map(dto, entity)); }
public static ProductStorageQuantity ToEntity(this ProductStorageQuantityDTO dto) { return(Mapper.Map <ProductStorageQuantityDTO, ProductStorageQuantity>(dto)); }