示例#1
0
        public async Task <BaseResponse <bool> > CreateYachtFileStream(YachtFileStreamCreateModel model)
        {
            try
            {
                var entity = new YachtFileStreams();
                entity                  = _mapper.Map <YachtFileStreamCreateModel, YachtFileStreams>(model, entity);
                entity.Deleted          = false;
                entity.ActivatedDate    = model.ActivatedDate;
                entity.LastModifiedBy   = GetUserGuidId();
                entity.LastModifiedDate = DateTime.Now;

                await _context.YachtFileStreams.AddAsync(entity);

                var result = await _context.SaveChangesAsync();

                if (result == 1)
                {
                    return(BaseResponse <bool> .Success(true));
                }
                return(BaseResponse <bool> .NoContent(false));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
        public async Task <IActionResult> CreateYachtFileStream(YachtFileStreamCreateModel model)
        {
            var res = await _yachtFileStreamService.CreateYachtFileStream(model);

            if (res.IsSuccessStatusCode)
            {
                return(Ok(res));
            }
            return(BadRequest());
        }