public ActionResult AddEducation(EducationData education)
        {
            education.UserId = User != null?User.Identity.GetUserId() : "";

            _educationSaveService.SaveEducation(education);
            if (Request != null && Request.IsAjaxRequest())
            {
                return(PartialView("AddEducation", _educationQueryService.GetAllEducation()));
            }

            return(RedirectToAction("Index", "Profile"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public EducationResult GetList(int eduTypeID, EducationListFilter filter, int?coustomPageSize = null, string isIndex = null)
        {
            EducationResult      result = new EducationResult();
            List <EducationData> data   = new List <EducationData>();

            using (var db = new TCGDB(_connectionString))
            {
                try
                {
                    var source = db.EDU
                                 .AsEnumerable()
                                 .Where(s => (string.IsNullOrEmpty(filter.LangCode) ? true : s.LANG_ID == filter.LangCode) &&
                                        s.STATUS == "Y" && s.CATE_ID == eduTypeID)
                                 .OrderByDescending(o => o.SORT) //排序大到小、發布日期新到舊、資料建檔日期新到舊
                                 .ThenByDescending(s => s.C_DATE)
                                 .ThenByDescending(d => d.BD_DT)
                                 .ToList();

                    foreach (var item in source)
                    {
                        EducationData temp = new EducationData()
                        {
                            ID                = item.ID,
                            Title             = item.C_TITLE,
                            PagingList        = GetPagingListByID(item.ID),
                            PublishDateString = item.C_DATE.Value.ToString("yyyy-MM-dd"),
                        };
                        temp.Remark = GetFirstPagingRemark(temp.PagingList);
                        data.Add(temp);
                    }

                    result.Data = data;
                    result      = this.ListPagination(ref result, filter.CurrentPage, coustomPageSize ?? Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            result.EduTypeInfo = GetEduCateByID(eduTypeID, filter.LangCode);
            return(result);
        }
 public EducationController(ApplicationDbContext context)
 {
     _repository = new EducationData(context);
 }
 public void SaveEducation(EducationData education)
 {
     _dataAccess.Educations.Insert(_mapper.Map <DataLayer.Entities.Profile.Education>(education));
 }