예제 #1
0
        public void Update(ComponentTypeDTO componentTypeDTO)
        {
            ComponentType componentType = Mapper.Map <ComponentType>(componentTypeDTO);

            _unitOfWork.ComponentTypes.Update(componentType);
            _unitOfWork.Save();
        }
예제 #2
0
        public void Add(ComponentTypeDTO componentTypeDTO)
        {
            ComponentType componentType = Mapper.Map <ComponentType>(componentTypeDTO);

            componentType.Id = Guid.NewGuid();

            _unitOfWork.ComponentTypes.Create(componentType);
            _unitOfWork.Save();
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "Name")] ComponentTypeVM componentTypeVM)
        {
            if (ModelState.IsValid)
            {
                ComponentTypeDTO componentTypeDTO = Mapper.Map <ComponentTypeDTO>(componentTypeVM);
                ComponentTypeService.Add(componentTypeDTO);

                return(RedirectToAction("Index"));
            }

            return(View());
        }
 public ActionResult Post([FromBody] ComponentTypeDTO value)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (value == null)
     {
         return(BadRequest());
     }
     repoWrapper.ComponentType.Insert(mapper.Map <ComponentType>(value));
     repoWrapper.Save();
     return(Ok());
 }
예제 #5
0
        public ActionResult Edit(Guid?id)
        {
            try
            {
                ComponentTypeDTO componentTypeDTO = ComponentTypeService.Get(id);
                ComponentTypeVM  componentTypeVM  = Mapper.Map <ComponentTypeVM>(componentTypeDTO);

                return(View(componentTypeVM));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadGateway));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
        }
        public ActionResult Put(Guid id, [FromBody] ComponentTypeDTO value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != value.Id)
            {
                return(BadRequest("Doesnt exist."));
            }
            var componentType = repoWrapper.ComponentType.GetById(id);

            if (componentType == null)
            {
                return(BadRequest());
            }
            mapper.Map <ComponentTypeDTO, ComponentType>(value, componentType);
            repoWrapper.Save();
            return(Ok());
        }