Ejemplo n.º 1
0
 /// <summary>
 /// 修改邮件
 /// </summary>
 /// <param name="emailInfo">邮件实体</param>
 public int UpdateEmail(EmailInfo emailInfo)
 {
     using (DataContextDB DB = new DataContextDB())
     {
         try
         {
             DB.GetTable<EmailInfo>().Attach(emailInfo, true);
             DB.SubmitChanges();
             return 1;
         }
         catch (Exception e)
         {
             string error = e.Message;
             return -1;
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加邮件
 /// </summary>
 /// <param name="emailInfo">邮件实体</param>
 public int InsertEmail(EmailInfo emailInfo)
 {
     using (DataContextDB DB = new DataContextDB())
     {
         try
         {
             DB.GetTable<EmailInfo>().InsertOnSubmit(emailInfo);
             DB.SubmitChanges();
             return 1;
         }
         catch (Exception e)
         {
             string error = e.Message;
             return -1;
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取邮件
        /// </summary>
        /// <param name="emailInfo">邮件实体</param>
        /// <param name="pageInfo">分页实体</param>
        /// <returns></returns>
        public IList<EmailInfo> GetEmail(EmailInfo emailInfo, PageInfo pageInfo)
        {
            using (DataContextDB DB = new DataContextDB())
            {
                IQueryable<EmailInfo> emailInfos =
                    (
                        from item in DB.GetTable<EmailInfo>()
                        orderby item.ID descending
                        select item
                    );
                if (emailInfo != null && emailInfo.ID != 0)
                    emailInfos = emailInfos.Where<EmailInfo>(m => m.ID == emailInfo.ID);
                if (emailInfo != null && emailInfo.UserID != 0)
                    emailInfos = emailInfos.Where<EmailInfo>(m => m.UserID == emailInfo.UserID);

                if (pageInfo != null)
                {
                    pageInfo.TotalRecord = emailInfos.Count();
                    return emailInfos.Skip(pageInfo.PageSize * (pageInfo.PageIndex - 1)).Take(pageInfo.PageSize).ToList<EmailInfo>();
                }
                else
                    return emailInfos.ToList<EmailInfo>();
            }
        }
Ejemplo n.º 4
0
        public ActionResult Email(EmailInfo emailInfo)
        {
            if (emailInfo == null) return Json(new FeedbackInfo { Success = -1, Message = "获取实体出错" });
            if (emailInfo.UserID == 0) return Json(new FeedbackInfo { Success = -1, Message = "请输入用户编号" });
            if (string.IsNullOrWhiteSpace(emailInfo.Subject)) return Json(new FeedbackInfo { Success = -1, Message = "请输入主题" });
            if (string.IsNullOrWhiteSpace(emailInfo.Memo)) return Json(new FeedbackInfo { Success = -1, Message = "请输入内容" });
            //新建
            int result = 0;
            if (emailInfo.ID == 0)
            {
                result = Start.DatabaseProvider.Instance().InsertEmail(emailInfo);
                if (result == 1)
                    return Json(new FeedbackInfo { Success = 1, Message = "添加成功" });
                else
                    return Json(new FeedbackInfo { Success = -1, Message = "添加失败" });
            }
            else //编辑
            {
                result = Start.DatabaseProvider.Instance().UpdateEmail(emailInfo);
                if (result == 1)
                    return Json(new FeedbackInfo { Success = 1, Message = "修改成功" });
                else
                    return Json(new FeedbackInfo { Success = -1, Message = "修改失败" });
            }

        }
Ejemplo n.º 5
0
 public ActionResult Email(int? id)
 {
     EmailInfo emailInfo = null;
     if (id != null && id.Value != 0) emailInfo = Start.DatabaseProvider.Instance().GetEmailByID(id.Value);
     if (emailInfo == null) emailInfo = new EmailInfo();
     return View(emailInfo);
 }
Ejemplo n.º 6
0
 public ActionResult EmailList(int userID = 0, int pageIndex = 1)
 {
     PageInfo pageInfo = new PageInfo { PageIndex = pageIndex };
     EmailInfo emailInfo = new EmailInfo { UserID = userID };
     IList<EmailInfo> emailInfos = Start.DatabaseProvider.Instance().GetEmail(emailInfo, pageInfo);
     PagedList<EmailInfo> pagedList = new PagedList<EmailInfo>(emailInfos, pageInfo.PageIndex, pageInfo.PageSize, pageInfo.TotalRecord);
     ViewBag.EmailInfo = emailInfo;
     return View(pagedList);
 }