Esempio n. 1
0
        public ActionResult EditInit(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(Json(null));
            }

            try
            {
                var jobId       = int.Parse(id);
                var checkResult = UserLogic.IsJobMaster(GetOperation().UserId, jobId);
                if (checkResult.IsSuccess == false)
                {
                    return(Json(checkResult));
                }

                var result = JobLogic.GetDetail(jobId);
                return(Json(result));
            }
            catch
            {
                var result = new IsSuccessResult(ErrorCode.JobNotFound.ToString());
                return(Json(result));
            }
        }
Esempio n. 2
0
        private static void ResultShouldBe(IsSuccessResult <BoardListDto> boardList, bool isSuccess, string errorMessage)
        {
            var expect = new IsSuccessResult <BoardListDto>()
            {
                IsSuccess    = isSuccess,
                ErrorMessage = errorMessage
            };

            boardList.ToExpectedObject().ShouldMatch(expect);
        }
Esempio n. 3
0
        private static void ResultShouldBe(IsSuccessResult <BoardListDto> actual, bool isSuccess, string errorMessage)
        {
            var expect = new IsSuccessResult <BoardQueryResp>
            {
                IsSuccess    = isSuccess,
                ErrorMessage = errorMessage
            };

            expect.ToExpectedObject().ShouldMatch(actual);
        }
Esempio n. 4
0
        private static void ResultShouldBeSuccess(IsSuccessResult <BoardListDto> actual, List <BoardListItem> boardListItems)
        {
            var expected = new IsSuccessResult <BoardListDto>()
            {
                IsSuccess    = true,
                ReturnObject = new BoardListDto()
                {
                    BoardListItems = boardListItems
                }
            };

            expected.ToExpectedObject().ShouldMatch(actual);
        }
Esempio n. 5
0
 public ActionResult DetailInit(string id)
 {
     try
     {
         var jobId  = int.Parse(id);
         var result = JobLogic.GetDetail(jobId);
         return(Json(result));
     }
     catch
     {
         var result = new IsSuccessResult(ErrorCode.JobNotFound.ToString());
         return(Json(result));
     }
 }
Esempio n. 6
0
 public ActionResult DetailInit(string id)
 {
     try
     {
         var companyId = int.Parse(id);
         var result    = VideoLogic.GetDetail(companyId);
         return(Json(result));
     }
     catch
     {
         var result = new IsSuccessResult(ErrorCode.VideoNotFound.ToString());
         return(Json(result));
     }
 }
Esempio n. 7
0
        public ActionResult EditInit(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(Json(null));
            }

            try
            {
                var blogId = int.Parse(id);
                var result = BlogLogic.GetDetail(blogId);
                return(Json(result));
            }
            catch
            {
                var result = new IsSuccessResult(ErrorCode.BlogNotFound.ToString());
                return(Json(result));
            }
        }
Esempio n. 8
0
        public IsSuccessResult <BlogInfo> GetDetail(int blogId)
        {
            var log = GetLogger();

            log.Debug("blogId: {0}", blogId);

            var blog = NiHonGoContext.Blogs
                       .SingleOrDefault(r => r.Id == blogId);

            var result = new IsSuccessResult <BlogInfo>();

            if (blog == null)
            {
                result.IsSuccess = false;
                result.ErrorCode = ErrorCode.BlogNotFound.ToString();
                return(result);
            }

            try
            {
                result.ReturnObject = new BlogInfo
                {
                    Title      = blog.Title,
                    Detail     = blog.Detail,
                    CreateDate = blog.CreateDate.ToLocalTime().ToString("yyyy-MM-dd"),
                    Photo      = blog.Photo,
                    Tag        = blog.Tag,
                    Catalog    = blog.Catalog.Display
                };

                return(result);
            }
            catch (Exception ex)
            {
                log.Error(ex);

                result.IsSuccess = false;
                result.ErrorCode = ErrorCode.InternalError.ToString();
                return(result);
            }
        }
Esempio n. 9
0
        public IsSuccessResult <WordInfo> GetDetail(int wordId)
        {
            var log = GetLogger();

            var word = NiHonGoContext.Words
                       .Include(r => r.Levels)
                       .SingleOrDefault(r => r.Id == wordId);

            if (word == null)
            {
                return(new IsSuccessResult <WordInfo>(ErrorCode.WordNotFound.ToString()));
            }

            try
            {
                var result = new IsSuccessResult <WordInfo>
                {
                    ReturnObject = new WordInfo
                    {
                        Id       = word.Id,
                        Japanese = word.Japanese,
                        Chinese  = word.Chinese,
                        Levels   = word.Levels
                                   .Select(r => new LevelInfo
                        {
                            Id      = r.Id,
                            Display = r.Display
                        }).ToList(),
                    }
                };

                return(result);
            }
            catch (Exception ex)
            {
                log.Error(ex);

                return(new IsSuccessResult <WordInfo>(ErrorCode.InternalError.ToString()));
            }
        }
Esempio n. 10
0
        public IsSuccessResult <GrammarInfo> GetDetail(int grammarId)
        {
            var log = GetLogger();

            var grammar = NiHonGoContext.Grammars
                          .Include(r => r.Levels)
                          .SingleOrDefault(r => r.Id == grammarId);

            if (grammar == null)
            {
                return(new IsSuccessResult <GrammarInfo>(ErrorCode.GrammarNotFound.ToString()));
            }

            try
            {
                var result = new IsSuccessResult <GrammarInfo>
                {
                    ReturnObject = new GrammarInfo
                    {
                        Id          = grammar.Id,
                        Title       = grammar.Title,
                        Description = grammar.Description,
                        Levels      = grammar.Levels
                                      .Select(r => new LevelInfo
                        {
                            Id      = r.Id,
                            Display = r.Display
                        }).ToList(),
                    }
                };

                return(result);
            }
            catch (Exception ex)
            {
                log.Error(ex);

                return(new IsSuccessResult <GrammarInfo>(ErrorCode.InternalError.ToString()));
            }
        }
Esempio n. 11
0
        public ActionResult Photo(string id)
        {
            var isSavedSuccessfully = true;
            var fName            = "";
            var defaultPhotoName = "temp" + GetOperation().UserId;
            var photoName        = defaultPhotoName;
            var checkResult      = new IsSuccessResult();

            try
            {
                photoName   = int.Parse(id).ToString();
                checkResult = UserLogic.IsJobMaster(GetOperation().UserId, int.Parse(id));
            }
            catch (Exception)
            {
            }

            if (checkResult.IsSuccess == false)
            {
                isSavedSuccessfully = false;
            }
            else
            {
                foreach (string fileName in Request.Files)
                {
                    var file = Request.Files[fileName];
                    fName = file.FileName;
                    if (file != null && file.ContentLength > 0)
                    {
                        var originalDirectory = new DirectoryInfo(string.Format("{0}MediaUpload\\", Server.MapPath(@"\")));
                        var pathString        = Path.Combine(originalDirectory.ToString(), "JobPhoto");
                        var isExists          = Directory.Exists(pathString);

                        if (!isExists)
                        {
                            Directory.CreateDirectory(pathString);
                        }

                        var ext       = Path.GetExtension(file.FileName);
                        var fileName1 = photoName + ext;
                        var path      = string.Format("{0}\\{1}", pathString, fileName1);
                        file.SaveAs(path);

                        if (photoName.Contains(defaultPhotoName) == false)
                        {
                            var result = JobLogic.UpdatePhoto(int.Parse(id), fileName1);
                            if (result.IsSuccess == false)
                            {
                                isSavedSuccessfully = false;
                            }
                        }
                    }
                }
            }

            if (isSavedSuccessfully)
            {
                return(Json(new { Message = fName }));
            }
            else
            {
                return(Json(new { Message = "Error in saving file" }));
            }
        }
Esempio n. 12
0
        public IsSuccessResult <VideoInfo> GetDetail(int videoId)
        {
            var log = GetLogger();

            var video = NiHonGoContext.Videos
                        .Include(r => r.Levels)
                        .Include(r => r.Words)
                        .Include(r => r.Grammars)
                        .SingleOrDefault(r => r.Id == videoId);

            var result = new IsSuccessResult <VideoInfo>();

            if (video == null)
            {
                return(new IsSuccessResult <VideoInfo>(ErrorCode.VideoNotFound.ToString()));
            }

            try
            {
                result.ReturnObject = new VideoInfo
                {
                    YoutubeUrl      = video.YoutubeUrl,
                    JapaneseTitle   = video.JapaneseTitle,
                    JapaneseContent = video.JapaneseContent,
                    ChineseTitle    = video.ChineseTitle,
                    ChineseContent  = video.ChineseContent,
                    Levels          = video.Levels.Select(r => new LevelInfo
                    {
                        Id      = r.Id,
                        Display = r.Display
                    }).ToList(),
                    Words = video.Words.Select(r => new WordInfo
                    {
                        Id       = r.Id,
                        Japanese = r.Japanese,
                        Chinese  = r.Chinese,
                        Levels   = r.Levels.Select(l => new LevelInfo
                        {
                            Id      = l.Id,
                            Display = l.Display
                        }).ToList()
                    }).ToList(),
                    Grammars = video.Grammars.Select(r => new GrammarInfo
                    {
                        Id          = r.Id,
                        Title       = r.Title,
                        Description = r.Description,
                        Levels      = r.Levels.Select(l => new LevelInfo
                        {
                            Id      = l.Id,
                            Display = l.Display
                        }).ToList()
                    }).ToList(),
                    CreateDateTime = video.CreateDateTime.ToLocalTime().ToString("yyyy-MM-dd"),
                    UpdateDateTime = video.UpdateDateTime.ToLocalTime().ToString("yyyy-MM-dd")
                };

                return(result);
            }
            catch (Exception ex)
            {
                log.Error(ex);

                result.IsSuccess = false;
                result.ErrorCode = ErrorCode.InternalError.ToString();
                return(result);
            }
        }