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

                if (pageInfo != null)
                {
                    pageInfo.TotalRecord = emailAddressInfos.Count();
                    return emailAddressInfos.Skip(pageInfo.PageSize * (pageInfo.PageIndex - 1)).Take(pageInfo.PageSize).ToList<EmailAddressInfo>();
                }
                else
                    return emailAddressInfos.ToList<EmailAddressInfo>();
            }
        }
Ejemplo n.º 4
0
        public ActionResult EmailAddress(EmailAddressInfo emailAddressInfo)
        {
            if (emailAddressInfo == null) return Json(new FeedbackInfo { Success = -1, Message = "获取实体出错" });
            if (emailAddressInfo.UserID == 0) return Json(new FeedbackInfo { Success = -1, Message = "请输入用户编号" });
            if (string.IsNullOrWhiteSpace(emailAddressInfo.Name)) return Json(new FeedbackInfo { Success = -1, Message = "请输入名称" });
            if (string.IsNullOrWhiteSpace(emailAddressInfo.Email)) return Json(new FeedbackInfo { Success = -1, Message = "请输入邮箱" });
            //新建
            int result = 0;
            if (emailAddressInfo.ID == 0)
            {
                result = Start.DatabaseProvider.Instance().InsertEmailAddress(emailAddressInfo);
                if (result == 1)
                    return Json(new FeedbackInfo { Success = 1, Message = "添加成功" });
                else
                    return Json(new FeedbackInfo { Success = -1, Message = "添加失败" });
            }
            else //编辑
            {
                result = Start.DatabaseProvider.Instance().UpdateEmailAddress(emailAddressInfo);
                if (result == 1)
                    return Json(new FeedbackInfo { Success = 1, Message = "修改成功" });
                else
                    return Json(new FeedbackInfo { Success = -1, Message = "修改失败" });
            }

        }
Ejemplo n.º 5
0
 public ActionResult EmailAddress(int? id)
 {
     EmailAddressInfo emailAddressInfo = null;
     if (id != null && id.Value != 0) emailAddressInfo = Start.DatabaseProvider.Instance().GetEmailAddressByID(id.Value);
     if (emailAddressInfo == null) emailAddressInfo = new EmailAddressInfo();
     return View(emailAddressInfo);
 }
Ejemplo n.º 6
0
 public ActionResult EmailAddressList(int userID = 0, int pageIndex = 1)
 {
     PageInfo pageInfo = new PageInfo { PageIndex = pageIndex };
     EmailAddressInfo emailAddressInfo = new EmailAddressInfo { UserID = userID };
     IList<EmailAddressInfo> emailAddressInfos = Start.DatabaseProvider.Instance().GetEmailAddress(emailAddressInfo, pageInfo);
     PagedList<EmailAddressInfo> pagedList = new PagedList<EmailAddressInfo>(emailAddressInfos, pageInfo.PageIndex, pageInfo.PageSize, pageInfo.TotalRecord);
     ViewBag.EmailAddressInfo = emailAddressInfo;
     return View(pagedList);
 }