예제 #1
0
        public async Task <ActionResult> DeleteTemplateAction(string ID)
        {
            try
            {
                if (!string.IsNullOrEmpty(ID))
                {
                    Guid     gid  = new Guid(ID);
                    Brochure find = await BrochureRepository.FindAsync(b => b.BrochureID == gid);

                    if (find != null)
                    {
                        if (BrochureRepository.Delete(find))
                        {
                            LogRepository.Add(new EventLog()
                            {
                                Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "删除宣传册模板事件成功"
                            });
                            return(Json(new
                            {
                                Success = true
                            }));
                        }
                    }
                }
                return(Json(new
                {
                    Success = false
                }));
            }
            catch (Exception ex)
            {
                LogRepository.Add(new EventLog()
                {
                    Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "删除宣传册模板事件失败" + ex.Message
                });
                return(Json(new
                {
                    Success = false
                }));
            }
        }
예제 #2
0
        public GetBrochureViewModel Delete(long id)
        {
            var brochure = _brochureRepository.Get(id);

            if (brochure == null)
            {
                throw new BusinessLogicException("Brochure not found");
            }

            var result = new GetBrochureViewModel()
            {
                Id            = brochure.Id,
                Name          = brochure.Name,
                TypeOfCover   = brochure.TypeOfCover,
                NumberOfPages = brochure.NumberOfPages
            };

            _brochureRepository.Delete(id);

            return(result);
        }