public void AddThemeTest()
        {
            var expected = new Theme("Test");
            var result   = _themeService.AddTheme(expected);

            Assert.AreEqual(expected.Name, result.Name);

            _themeService.DeleteTheme(result.ThemeId);
        }
Example #2
0
        public ActionResult Create(Theme theme, HttpPostedFileBase uploadFile)
        {
            if (!ClaimsPrincipal.Current.IsInRole(GeonorgeRoles.MetadataAdmin))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            if (uploadFile != null)
            {
                if (!(uploadFile.ContentType == "image/jpeg" || uploadFile.ContentType == "image/gif" ||
                      uploadFile.ContentType == "image/png" || uploadFile.ContentType == "image/svg+xml"))
                {
                    ModelState.AddModelError(string.Empty, "Thumnail må være bilde format");
                }
                else
                {
                    theme.ThumbnailUrl = SaveFile(theme, uploadFile);
                }
            }

            if (ModelState.IsValid)
            {
                _themeService.AddTheme(theme);
                return(RedirectToAction("Index"));
            }

            ViewBag.ParentId = new SelectList(_themeService.GetThemes(), "Id", "Name", theme.ParentId);
            return(View(theme));
        }
Example #3
0
        public ActionResult Add(ThemeView theme)
        {
            var result = _themeService.AddTheme(theme.Map());

            if (result != null)
            {
                TempData["Success"] = "Theme successfully created!";
                Logger.Log.Info($"Theme with Name - {theme.Name}, created successfully.");
                return(RedirectToAction("List"));
            }
            Logger.Log.Info($"Theme with Name - {theme.Name}, already exists!");
            TempData["Error"] = "Theme already exists!";
            return(View());
        }
Example #4
0
        public async Task <ActionResult <bool> > AddTheme([FromBody] AddThemeModel model)
        {
            if (model == null)
            {
                return(BadRequest("Model is empty"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is not valid"));
            }

            return(Ok(await _themeService.AddTheme(model)));
        }
Example #5
0
        public ActionResult UpdateTheme(Theme theme)
        {
            if (ModelState.IsValid)
            {
                if (theme.Id == 0)
                {
                    themeService.AddTheme(theme);
                }

                themeService.UpdateTheme(theme);

                ViewBag.Message = "Изменения в теме были сохранены";
            }
            return(PartialView("Modal/_ThemePartial", theme));
        }
        /// <summary>
        /// 商城主题设置设置,如果有数据即修改
        /// </summary>
        /// <param name="mTheme">主题实体类</param>
        public static void SetTheme(Himall.DTO.Theme mVTheme)
        {
            new Himall.Model.UserMemberInfo();

            Mapper.CreateMap <Himall.DTO.Theme, Himall.Model.ThemeInfo>();
            var mTheme = Mapper.Map <Himall.DTO.Theme, Himall.Model.ThemeInfo>(mVTheme);

            if (mVTheme.ThemeId <= 0)
            {
                _iThemeService.AddTheme(mTheme);
            }
            else
            {
                _iThemeService.UpdateTheme(mTheme);
            }
        }
Example #7
0
        public async Task <IActionResult> AddTheme(AddThemeViewModel input)
        {
            if (input.Title == null)
            {
                return(this.RedirectToAction("Index", "Home"));
            }

            if (!this.ModelState.IsValid)
            {
                return(View(input));
            }

            input.PhotographyAddictedUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            await themeService.AddTheme(input);

            return(this.RedirectToAction("PreviewThemes", "Themes"));
        }
Example #8
0
        /// <summary>
        /// 商城主题设置设置,如果有数据即修改
        /// </summary>
        /// <param name="mTheme">主题实体类</param>
        public static void SetTheme(Mall.DTO.Theme mVTheme)
        {
            new Mall.Entities.MemberInfo();

            // Mapper.CreateMap<Mall.DTO.Theme, Mall.Entities.ThemeInfo>();
            //var mTheme = Mapper.Map<Mall.DTO.Theme, Mall.Entities.ThemeInfo>(mVTheme);

            var mTheme = mVTheme.Map <Mall.Entities.ThemeInfo>();


            if (mVTheme.ThemeId <= 0)
            {
                _iThemeService.AddTheme(mTheme);
            }
            else
            {
                _iThemeService.UpdateTheme(mTheme);
            }
        }
        public IActionResult CreateTheme(ThemeViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (_themeService.GetThemes().Any(t => t.Theme_type == model.Theme_type))
                {
                    ModelState.AddModelError("", "This theme is already exist!");
                    AdminPanelViewModel ViewModel = new AdminPanelViewModel();
                    var MappedModel = MappingAdminModel(ViewModel).Result;
                    MappedModel.Theme = model;
                    return(View("Panel", MappedModel));
                }


                _themeService.AddTheme(model.Theme_type);
            }

            return(RedirectToAction(nameof(Panel)));
        }
        public void AddCourseTest()
        {
            var theme  = new Theme("Test");
            var result = _themeService.AddTheme(theme);

            theme = _themeService.GetThemeByName("Test");
            var teacher = new User("*****@*****.**", "", new List <Course>());

            _userService.AddTeacher(teacher, "Password_22");
            teacher = _userService.GetTeacherByEmail("*****@*****.**");
            var expected = new Course(0, theme, "aCourse", new DateTime(2020, 4, 14), new DateTime(2020, 4, 18), teacher);

            _courseService.AddCourse(expected);
            var res = _courseService.GetCourseByName("aCourse");

            Assert.AreEqual(expected.Name, res.Name);
            Assert.AreEqual(expected.Start, res.Start);
            Assert.AreEqual(expected.End, res.End);
            Assert.AreEqual(expected.Theme.Name, res.Theme.Name);
            Assert.AreEqual(expected.Teacher.Name, res.Teacher.Name);
            _courseService.DeleteCourse(res.CourseId);
        }