/// <summary> /// 新增公告 /// </summary> public virtual async Task <NoticeEditDto> CreateNoticeAsync(NoticeEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 var entity = input.MapTo <Notice>(); entity = await noticeservice.InsertAsync(entity); return(entity.MapTo <NoticeEditDto>()); }
/// <summary> /// 编辑公告 /// </summary> public virtual async Task UpdateNoticeAsync(NoticeEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await noticeservice.GetAsync(input.Id.Value); input.MapTo(entity); await noticeservice.UpdateAsync(entity); }
/// <summary> /// 通过Id获取公告信息进行编辑或修改 /// </summary> public GetNoticeForEditOutput GetNoticeForEdit(NullableIdDto <long> input) { var output = new GetNoticeForEditOutput(); NoticeEditDto NoticeEditDto; if (input.Id.HasValue) { var entity = noticeservice.Get(input.Id.Value); NoticeEditDto = entity.MapTo <NoticeEditDto>(); } else { NoticeEditDto = new NoticeEditDto(); } output.Notice = NoticeEditDto; return(output); }
public ActionResult Save(NoticeEditDto dto) { try { if (dto.Content != null) { dto.Content = HttpUtility.HtmlDecode(dto.Content.Replace(Environment.NewLine, "<br>")); } noticeservice.CreateOrUpdateNoticeAsync(new CreateOrUpdateNoticeInput { NoticeEditDto = dto }); return(RedirectToAction("/Index")); } catch { return(View()); } }
public NoticeEditViewModel(NoticeEditDto dto) { dto.MapTo(this); }