예제 #1
0
        public async Task <IActionResult> CreateYachtTourCharterProcessingFeesAsync([FromBody] YachtTourCharterProcessingFeesCreateModel requestModel)
        {
            var result = await _yachtTourCharterProcessingFeesService.CreateYachtTourCharterProcessingFees(requestModel);

            if (result.IsSuccessStatusCode)
            {
                return(Ok(result));
            }
            return(BadRequest());
        }
        public async Task <BaseResponse <bool> > CreateYachtTourCharterProcessingFees(YachtTourCharterProcessingFeesCreateModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                var checkExistEntity = _context.YachtTourCharterProcessingFees.Find(model.TourCharterFid);
                if (checkExistEntity == null)
                {
                    var entity = new YachtTourCharterProcessingFees();
                    entity.InjectFrom(model);
                    entity.GeneratedDate    = DateTime.Now;
                    entity.LastModifiedBy   = GetUserGuidId();
                    entity.LastModifiedDate = DateTime.Now;

                    await _context.YachtTourCharterProcessingFees.AddAsync(entity);

                    await _context.SaveChangesAsync();

                    return(BaseResponse <bool> .Success(true));
                }
                else
                {
                    return(BaseResponse <bool> .NotFound(message : "Duplicated"));
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message));
            }
        }