Ejemplo n.º 1
0
 public IHttpActionResult AddUnit(HttpRequestMessage requestMessage, Unit newUnit)
 {
     // Delegate all work to maintenance processor
     var unit = _addUnitMaintenanceProcessor.AddUnit(newUnit);
     var result = new CreatedActionResult<Unit>(unit, requestMessage);
     return result;
 }
Ejemplo n.º 2
0
 public void AddLinks(Unit unit)
 {
     AddAllUnitsLink(unit);
     AddUpdateUnitLink(unit);
     AddDeleteUnitLink(unit);
     AddCreateNewUnitLink(unit);
     AddLinksToChildren(unit);
 }
        public Unit AddUnit(Unit newUnit)
        {
            // Map service model to entity model
            var unitEntity = _autoMapper.Map<Data.Entities.Unit>(newUnit);

            // Persist entity model
            _queryProcessor.AddUnit(unitEntity);

            // Map new entity model back to full service model
            var unit = _autoMapper.Map<Unit>(unitEntity);

            // Add links to service model
            _unitLinkService.AddLinks(unit);

            return unit;
        }
Ejemplo n.º 4
0
 public virtual void AddUpdateUnitLink(Unit unit)
 {
     var pathFragment = string.Format("{0}/{1}", PathFragmentBase, unit.UnitId);
     var link = _commonLinkService.GetLink(pathFragment, "updateUnit", HttpMethod.Put);
     unit.AddLink(link);
 }
Ejemplo n.º 5
0
 public virtual void AddLinksToChildren(Unit unit)
 {
     _technologyLinkService.AddSelfLink(unit.Technology);
 }
Ejemplo n.º 6
0
 public virtual void AddCreateNewUnitLink(Unit unit)
 {
     var link = _commonLinkService.GetLink(PathFragmentBase, "createUnit", HttpMethod.Post);
     unit.AddLink(link);
 }
Ejemplo n.º 7
0
 public virtual void AddAllUnitsLink(Unit unit)
 {
     var link = _unitPrecisLinkService.GetAllUnitsLink();
     unit.AddLink(link);
 }