public async Task <ActionResult> PostManufacturer(ManufacturerCreate manufacturer)
        {
            _bll.Manufacturers.AddNoReturn(_mapper.MapToBLL(manufacturer));
            await _bll.SaveChangesAsync();

            return(Ok());
        }
Exemple #2
0
 public BLL.App.DTO.ManufacturerMinimal MapToBLL(ManufacturerCreate apiManufacturer)
 {
     return(new BLL.App.DTO.ManufacturerMinimal
     {
         Id = 0,
         ManufacturerName = apiManufacturer.ManufacturerName,
     });
 }
        public async Task <bool> CreateManufacturer(ManufacturerCreate model)
        {
            var entity = new Manufacturer()
            {
                CompanyName = model.CompanyName,
                Locations   = model.Locations,
                Founded     = model.Founded
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Manufacturers.Add(entity);

                return(await ctx.SaveChangesAsync() == 1);
            }
        }
        public async Task <IHttpActionResult> PostAsync(ManufacturerCreate manufacturer)
        {
            var service = CreateManufacturerService();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (!(await service.CreateManufacturer(manufacturer)))
            {
                return(InternalServerError());
            }

            return(Ok(manufacturer));
        }