Example #1
0
        public Manufacturer Post(ManufacturerDTO value)
        {
            Manufacturer manufacturer = new Manufacturer()
            {
                Name     = value.Name,
                Location = value.Location
            };

            return(IManufacturerRepo.Create(manufacturer));
        }
Example #2
0
        public UnitOfWork(DbContext context)
        {
            this.Context = context;

            product      = new ProductRepo(context);
            type         = new TypeRepo(context);
            typeopt      = new TypeOptRepo(context);
            typespec     = new TypeSpecRepo(context);
            manufacturer = new ManufacturerRepo(context);
        }
Example #3
0
        public Manufacturer Delete(int id)
        {
            Manufacturer manufacturer = IManufacturerRepo.Get(id);

            foreach (Component component in IComponentRepo.GetAll())
            {
                if (component.ManufacturerId == id)
                {
                    IComponentRepo.Delete(component);
                }
            }
            return(IManufacturerRepo.Delete(manufacturer));
        }
Example #4
0
        public void Put(int id, ManufacturerDTO value)
        {
            Manufacturer manufacturer = IManufacturerRepo.Get(id);

            if (value.Name != null)
            {
                manufacturer.Name = value.Name;
            }
            if (value.Location != null)
            {
                manufacturer.Location = value.Location;
            }

            IManufacturerRepo.Update(manufacturer);
        }
Example #5
0
        public ManufacturerDetailsDTO Get(int id)
        {
            Manufacturer           manufacturer        = IManufacturerRepo.Get(id);
            ManufacturerDetailsDTO manufacturerDetails = new ManufacturerDetailsDTO()
            {
                Name     = manufacturer.Name,
                Location = manufacturer.Location
            };

            IEnumerable <Component> components = IComponentRepo.GetAll().Where(x => x.ManufacturerId == manufacturer.Id);

            if (components != null)
            {
                List <string> componentsName = new List <string>();
                foreach (Component component in components)
                {
                    componentsName.Add(component.Name);
                }
                manufacturerDetails.Components = componentsName;
            }

            return(manufacturerDetails);
        }
Example #6
0
 public ManufacturersController(IManufacturerRepo repository, IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
 }
Example #7
0
 public ActionResult <IEnumerable <Manufacturer> > Get()
 {
     return(IManufacturerRepo.GetAll());
 }
Example #8
0
 public HomeController(IManufacturerRepo manufacturer)
 {
     _manufacturer = manufacturer;
 }