Exemple #1
0
        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));
        }
Exemple #2
0
        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()));
        }
Exemple #3
0
 public static ProductStorageQuantity ToEntity(this ProductStorageQuantityDTO dto, ProductStorageQuantity entity)
 {
     return(Mapper.Map(dto, entity));
 }
Exemple #4
0
 public static ProductStorageQuantity ToEntity(this ProductStorageQuantityDTO dto)
 {
     return(Mapper.Map <ProductStorageQuantityDTO, ProductStorageQuantity>(dto));
 }