예제 #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;
 }
예제 #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;
        }
예제 #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);
 }
예제 #5
0
 public virtual void AddLinksToChildren(Unit unit)
 {
     _technologyLinkService.AddSelfLink(unit.Technology);
 }
예제 #6
0
 public virtual void AddCreateNewUnitLink(Unit unit)
 {
     var link = _commonLinkService.GetLink(PathFragmentBase, "createUnit", HttpMethod.Post);
     unit.AddLink(link);
 }
예제 #7
0
 public virtual void AddAllUnitsLink(Unit unit)
 {
     var link = _unitPrecisLinkService.GetAllUnitsLink();
     unit.AddLink(link);
 }