예제 #1
0
        public ServiceResult Create(BlogsDTO model)
        {
            var entity = new Blogs();

            Mapper.Map(model, entity);

            _blogs.Add(entity);
            _Context.SaveChanges();

            return(ServiceResult.Okay());
        }
예제 #2
0
        public IActionResult Create(BlogsDTO model, IFormFile Image)
        {
            var imageName = FileHelper.SaveFile(Image, _fileConfig, FileType.Image, _environment.WebRootPath);

            if (imageName != null)
            {
                model.Image = imageName;
            }
            var result = _blogsRepository.Create(model);

            TempData.AddResult(result);
            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
        /// <summary>
        /// 保存内容
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public string SaveBlogs(BlogsDTO dto)
        {
            var entity = Mapper.Map <BlogsDTO, Blogs>(dto);

            try
            {
                blogs.Add(entity);
                return("操作成功");
            }
            catch (Exception e)
            {
                return("内部出现错误");
            }
        }
예제 #4
0
파일: BlogBL.cs 프로젝트: gabod2000/grubNow
        public async Task <BlogsDTO> GetById(int Id)
        {
            var      states = _BusinessBase.GetById(Id);
            BlogsDTO state  = new BlogsDTO();

            if (states != null)
            {
                state.Id             = states.Id;
                state.Description    = states.Description;
                state.Heading        = states.Heading;
                state.ImagesUrl      = states.ImagesUrl;
                state.OtherImagesUrl = states.OtherImagesUrl;
                state.UserName       = states.UserName;
                state.UserId         = states.UserId;
            }
            return(state);
        }
예제 #5
0
파일: BlogBL.cs 프로젝트: gabod2000/grubNow
        public async Task <IEnumerable <BlogsDTO> > Get()
        {
            var             states    = _BusinessBase.Get();
            List <BlogsDTO> stateslst = null;

            if (states != null)
            {
                stateslst = new List <BlogsDTO>();
                foreach (var item in states)
                {
                    BlogsDTO state = new BlogsDTO();
                    state.Id             = item.Id;
                    state.Description    = item.Description;
                    state.Heading        = item.Heading;
                    state.ImagesUrl      = item.ImagesUrl;
                    state.OtherImagesUrl = item.OtherImagesUrl;
                    state.UserName       = item.UserName;
                    state.UserId         = item.UserId;
                    stateslst.Add(state);
                }
            }
            return(stateslst);
        }
예제 #6
0
        public HttpResponseMessage SaveBlogs(BlogsDTO dto)
        {
            string result = service.SaveBlogs(dto);

            return(HttpResponseExtension.toJson(result));
        }