예제 #1
0
        private CharService CreateCharService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);

            return(service);
        }
예제 #2
0
        public ActionResult Hanzi(Word word)
        {
            Models.CharacterViewModel charViewModel = new Models.CharacterViewModel();

            CharService       charService       = new CharService();
            PhrasesService    phrasesService    = new PhrasesService();
            DictionaryService dictionaryService = new DictionaryService();

            charViewModel.word = word;

            if (word.Character.Length == 1)
            {
                string NumberPinyin = word.NumberPinyin;

                charViewModel.AudioSource = "../Audio/" + NumberPinyin + ".mp3";
            }


            //TODO
            ArrayList   getPhrasesArrayList = phrasesService.GetPhrasesContainingCharacter(word.Character);
            List <Word> getPhraseslist      = ToList(getPhrasesArrayList);

            ArrayList   getIdiomsArrayList = dictionaryService.GetIdiomsContainingCharacter(word.Character);
            List <Word> getIdiomslist      = ToList(getIdiomsArrayList);

            ArrayList   getImagePhrasesArrayList = phrasesService.GetImagePhrasesContainingCharacter(word.Character);
            List <Word> getImagePhraseslist      = ToList(getImagePhrasesArrayList);


            charViewModel.PhrasesContainingCharacter      = getPhraseslist;
            charViewModel.ImagePhrasesContainingCharacter = getImagePhraseslist;
            charViewModel.IdiomsContainingCharacter       = getIdiomslist;

            return(View(charViewModel));
        }
예제 #3
0
        public ActionResult Index()
        {
            CharService charService = new CharService();

            Word ch = charService.GetRandomChar300();

            return(View(ch));
        }
예제 #4
0
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);
            var model   = service.GetCharacters();

            return(View(model));
        }
예제 #5
0
        // GET: Character/Delete/5
        public ActionResult Delete(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);

            var model = service.GetCharacterById(id);

            return(View(model));
        }
예제 #6
0
        public ActionResult DeleteCharacter(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);

            if (service.DeleteCharacter(id))
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Delete", new { id }));
        }
예제 #7
0
        public ActionResult Create(CharCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);

            if (service.Create(model))
            {
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Character could not be added");
            return(View(model));
        }
예제 #8
0
        // GET: Character/Details/5
        public ActionResult Details(int?id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);
            var model   = service.GetCharacterById(id);

            //var charRaceService = new CharRaceServices();
            //var raceList = charRaceService.GetRaces();

            //ViewBag.CharRaceID = new SelectList(raceList, "ID", "RaceName");

            //var charClassService = new CharClassServices();
            //var classList = charClassService.GetClasses();

            //ViewBag.CharClassID = new SelectList(classList, "ID", "ClassName");

            return(View(model));
        }
예제 #9
0
        // GET: Character/Edit/5
        public ActionResult Edit(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);

            var charClassService = new CharClassServices();
            var classList        = charClassService.GetClasses();

            ViewBag.CharClassID = new SelectList(classList, "ID", "ClassName");

            var detail = service.GetCharacterById(id);
            var model  = new CharDetail
            {
                CharName         = detail.CharName,
                CharClassID      = detail.CharClassID,
                Alignment        = detail.Alignment,
                CharHistory      = detail.CharHistory,
                ExperiencePoints = detail.ExperiencePoints,
                Traits           = detail.Traits,
                Level            = detail.Level,
            };

            return(View(model));
        }