public IActionResult ServiceControlByProductId(int additionalId, [FromBody] YachtAdditionalServiceControlSearchModel model)
        {
            var result = _yachAdditionalService.AdditionalServiceControls(additionalId, model);

            if (result.IsSuccessStatusCode)
            {
                return(Ok(result));
            }
            return(BadRequest());
        }
Пример #2
0
        public BaseResponse <PagedList <YachtAdditionalServiceControlModel> > AdditionalServiceControls(int additionalId, YachtAdditionalServiceControlSearchModel model)
        {
            try
            {
                var pageSize  = model.PageSize > 0 ? model.PageSize : 10;
                var pageIndex = model.PageIndex > 0 ? model.PageIndex : 1;
                var query     = (from v in _context.YachtAdditionalServices
                                 join s in _context.YachtAdditionalServiceControls on v.Id equals s.AdditionalServiceFid
                                 where s.Deleted == false && v.Deleted == false && s.AdditionalServiceFid == additionalId
                                 select new YachtAdditionalServiceControlModel()
                {
                    YachtFid = s.YachtFid,
                    AdditionalServiceFid = s.AdditionalServiceFid,
                    YachtName = _context.Yachts.FirstOrDefault(x => x.Id == s.YachtFid) != null ?
                                _context.Yachts.FirstOrDefault(x => x.Id == s.YachtFid).Name : string.Empty,
                    EffectiveDate = s.EffectiveDate,
                    EffectiveEndDate = s.EffectiveEndDate,
                    Remark = s.Remark
                }).OrderBy(m => m.EffectiveDate).ThenBy(m => m.EffectiveDate);
                var result = new PagedList <YachtAdditionalServiceControlModel>(query, pageIndex, pageSize);

                return(BaseResponse <PagedList <YachtAdditionalServiceControlModel> > .Success(result));
            }
            catch (Exception ex)
            {
                return(BaseResponse <PagedList <YachtAdditionalServiceControlModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }