// GET api/charter/5
        public CharterDto GetById(CharterType charterType, CharterStateTypeEnum charterStateTypeEnum, long id)
        {
            var res = new CharterDto();
            if (charterType == CharterType.In)
            {
                if (charterStateTypeEnum == CharterStateTypeEnum.Start)
                {
                    res = this._charterInFacadeService.GetById(id);
                }
                else
                {
                    res = this._charterInFacadeService.GetCharterEnd(id);
                }

            }
            else
            {
                if (charterStateTypeEnum == CharterStateTypeEnum.Start)
                {
                    res = this._charterOutFacadeService.GetById(id);
                }
                else
                {
                    res = this._charterOutFacadeService.GetCharterEnd(id);
                }
            }

            return res;
        }
 public void Add(CharterDto data)
 {
     if (data.CharterStateType == CharterStateTypeEnum.Start)
     {
         _charterInApplicationService.AddStart(data.Charterer.Id, data.Owner.Id, data.Vessel.Id,
             data.Currency.Id, data.StartDate, _charterInToDtoMapper.DtoToOfHreConvertor(data.OffHirePricingType));
     }
     else
     {
         _charterInApplicationService.AddEnd(data.Charterer.Id, data.Owner.Id, data.Vessel.Id,
               data.Currency.Id, data.EndDate, _charterInToDtoMapper.CharterEndTypeEnumConvertor(data.CharterEndType), _charterInToDtoMapper.DtoToOfHreConvertor(data.OffHirePricingType));
     }
 }
 public void Add(Action<CharterDto, Exception> action, CharterDto charterDto)
 {
     var uri = String.Concat(hostCharterAddressController, "?charterType=" + CharterType.Out);
     WebClientHelper.Post<CharterDto, CharterDto>(new Uri(uri, UriKind.Absolute), action, charterDto, WebClientHelper.MessageFormat.Json,ApiConfig.Headers);
 }
        public CharterDto GetCharterEnd(long startId)
        {
            var entity = _charterInRepository.GetCharterEnd(startId);
            var res = new CharterDto();

            if (entity != null)
            {
                res = _charterInToDtoMapper.MapToDtoModel(entity);

                if (entity.CharterItems.Count > 0)
                {
                    var items = _charterItemToDtoMapper.MapToDtoModels(
                        new PageResult<CharterItem>() {Result = entity.CharterItems});
                    items.Result.ToList().ForEach(c => res.CharterItems.Add(c));
                }

                if (entity.InventoryOperationItems.Count > 0)
                {
                    var invOperts = _charterInToDtoMapper.MapToInvDtoModels(
                        new PageResult<InventoryOperation>() {Result = entity.InventoryOperationItems});
                    invOperts.Result.ToList().ForEach(c => res.InventoryOperationDtos.Add(c));
                }
                return res;
            }
            else
            {
                return null;
            }
        }
 public void Update(Action<CharterDto, Exception> action, long id, CharterDto charterDto)
 {
     string uri = String.Concat(String.Format(hostCharterAddressController, id), "?charterType=" + CharterType.In);
     WebClientHelper.Put<CharterDto, CharterDto>(new Uri(uri, UriKind.Absolute), action, charterDto, WebClientHelper.MessageFormat.Json,ApiConfig.Headers);
 }