Esempio n. 1
0
        public IActionResult UpdateUnit(int id, [FromBody] UnitResource unitResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var unit = unitRepository.Get(id);

            mapper.Map(unitResource, unit);

            uow.Complete();
            var result = mapper.Map <Unit, UnitResource>(unit);

            return(Ok(result));
        }
Esempio n. 2
0
        public IActionResult CreateUnit([FromBody] UnitResource unitResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var unit = mapper.Map <UnitResource, Unit>(unitResource);

            unitRepository.Add(unit);
            uow.Complete();

            var result = mapper.Map <Unit, UnitResource>(unit);

            return(Ok(result));
        }
Esempio n. 3
0
 private UnitVM CreateItem(UnitResource unit) => new UnitVM()
 {
     Model               = unit,
     PreviewProvider     = PreviewProvider,
     AbilityListProvider = AbilityListProvider
 };