Beispiel #1
0
        private async Task <BaseResult> Create(CategoryLecture categoryLecture)
        {
            var result = new BaseResult();

            var exist = CategoryLectureRepository.QueryAll().FirstOrDefault(
                x => x.CategoryId == categoryLecture.CategoryId &&
                x.LectureId == categoryLecture.LectureId);

            if (exist != null)
            {
                try
                {
                    exist.IsDeleted = false;
                    await CategoryLectureRepository.UpdateAsync(exist);
                }
                catch (Exception e)
                {
                    result.Result  = Result.SystemError;
                    result.Message = e.ToString();
                }
            }
            else
            {
                try
                {
                    await CategoryLectureRepository.InsertAsync(categoryLecture);
                }
                catch (Exception e)
                {
                    result.Result  = Result.SystemError;
                    result.Message = e.ToString();
                }
            }
            return(result);
        }
Beispiel #2
0
 public static CategoryLectureItem ToItem(this CategoryLecture entity)
 {
     return(entity.MapTo <CategoryLecture, CategoryLectureItem>());
 }
Beispiel #3
0
 public static CategoryLecture ToCategoryLecture(this CategoryLecture entity, CategoryLecture destination)
 {
     return(entity.MapTo(destination));
 }
Beispiel #4
0
 public static CategoryLectureModel ToModel(this CategoryLecture entity)
 {
     return(entity.MapTo <CategoryLecture, CategoryLectureModel>());
 }