Example #1
0
 public IActionResult AddSection(SectionVm c)
 {
     if (ModelState.IsValid)
     {
         var i = _context.Section.AsNoTracking().Where(s => s.SectionName == c.SectionName).FirstOrDefault();
         if (i == null)
         {
             Section cs = new Section()
             {
                 SectionId   = c.SectionId,
                 SectionName = c.SectionName
             };
             _context.Section.Add(cs);
             _context.SaveChanges();
             return(RedirectToAction("SectionList"));
         }
         else
         {
             ViewBag.SMS = "You Have Already this Section";
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }
Example #2
0
        public ActionResult Add()
        {
            SectionVm vm = new SectionVm();

            PrepareViewModel(vm);
            return(View(vm));
        }
Example #3
0
        public ActionResult Add(SectionVm section)
        {
            if (!_customUrlService.IsUniquePath(section.Path))
            {
                ModelState.AddModelError("Path", "Путь не уникален");
            }
            if (ModelState.IsValid)
            {
                var model = Mapper.Map <SectionVm, Section>(section);
                model.SectionState = SectionState.Active;
                model = _sectionService.Create(model);

                if (!string.IsNullOrEmpty(section.Path))
                {
                    var customUrlModel = new CustomUrl();
                    customUrlModel.Url         = model.Path;
                    customUrlModel.ContentType = ContentType.Section;
                    customUrlModel.ContentId   = model.Id;
                    _customUrlService.Create(customUrlModel);
                    //TODO: remove (temporary for output cache)
                    MemoryCacheHelper.SectionsUpdateTime = DateTime.Now;
                }

                return(RedirectToAction("Index"));
            }
            return(View(section));
        }
Example #4
0
        public IActionResult SectionList(int Page = 1)
        {
            var r = _context.Section.ToList();

            if (r.Count == 0)
            {
                return(RedirectToAction("Error"));
            }
            List <SectionVm> rl = new List <SectionVm>();
            int c = 1;

            foreach (var item in r)
            {
                SectionVm rlvm = new SectionVm()
                {
                    Sl          = c,
                    SectionId   = item.SectionId,
                    SectionName = item.SectionName
                };
                rl.Add(rlvm);
                c++;
            }
            var list = rl.ToPagedList(Page, 5);///Converting The ClassList into XPageList

            return(View(list));
        }
        // GET: Sections/SaveSection
        public IActionResult SaveSection(int tournamentId)
        {
            SectionVm  viewModel  = new SectionVm();
            Tournament tournament = _tournamentManagement.GetTournamentById(tournamentId);

            viewModel.TournamentId = tournament.TournamentId;
            viewModel.Tournament   = tournament;
            return(View("SectionAdminForm", viewModel));
        }
Example #6
0
 private void PrepareViewModel(SectionVm vm)
 {
     vm.Order = new BsRangeItem <int>
     {
         MinValue  = 0,
         MaxValue  = 100,
         TextValue = "0-100",
         Display   = Resources.Resources.SectionVm_Order
     };
 }
Example #7
0
        public ActionResult Edit(int id)
        {
            var       section = _sectionService.GetById(id);
            SectionVm vm      = Mapper.Map <Section, SectionVm>(section);

            var customUrl = _customUrlService.GetAll().FirstOrDefault(x => x.ContentId == vm.Id && x.ContentType == ContentType.Section);

            vm.Path = customUrl != null ? customUrl.Url : String.Empty;

            return(View(vm));
        }
        public IActionResult Edit(int id)
        {
            var       Section   = db.Section.Get(id);
            SectionVm sectionVm = new SectionVm();

            sectionVm.Id          = Section.Id;
            sectionVm.Name        = Section.Name;
            sectionVm.Description = Section.Description;
            sectionVm.Phone       = Section.Phone;
            sectionVm.Email       = Section.Email;
            sectionVm.IsActive    = Section.IsActive;

            return(PartialView("_EditView", sectionVm));
        }
Example #9
0
        public IActionResult UpdateSection(int id)
        {
            Section i = _context.Section.AsNoTracking().Where(q => q.SectionId == id).FirstOrDefault();

            if (i == null)
            {
                return(RedirectToAction("Error"));
            }
            SectionVm l = new SectionVm()
            {
                SectionId   = i.SectionId,
                SectionName = i.SectionName
            };

            return(View(l));
        }
        // GET: Section/SaveTeam/5
        public IActionResult Edit(int id)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            var section = _sectionManagement.GetSectionById(id);

            SectionVm viewModel = new SectionVm(section)
            {
                Tournament = _tournamentManagement.GetTournamentById(section.TournamentId),
                Teams      = _teamManagement.GetTeamsForSection(id)
            };

            return(View("SectionAdminForm", viewModel));
        }
        public IActionResult Delete(SectionVm sectionVm)
        {
            if (ModelState.IsValid)
            {
                Section section = db.Section.GetFirstOrDefault(c => c.Id == sectionVm.Id);

                section.IsActive  = false;
                section.IsDeleted = true;

                db.Section.Update(section);
                bool isUpdated = db.Save() > 0;

                return(Json(sectionVm));
            }
            sectionVm.IsValid = false;
            sectionVm.Message = "Validation Failed!. Please try Again with valid data.";
            return(Json(sectionVm));
        }
Example #12
0
 public IActionResult UpdateSection(SectionVm u)
 {
     if (ModelState.IsValid)
     {
         Section l = new Section()
         {
             SectionId   = u.SectionId,
             SectionName = u.SectionName
         };
         _context.Section.Update(l);
         _context.SaveChanges();
         return(RedirectToAction("SectionList"));
     }
     else
     {
         return(View());
     }
 }
        public IActionResult Edit(SectionVm sectionVm)
        {
            if (ModelState.IsValid)
            {
                Section section = db.Section.GetFirstOrDefault(c => c.Id == sectionVm.Id);

                section.Id          = sectionVm.Id;
                section.Name        = sectionVm.Name;
                section.Description = sectionVm.Description;
                section.Phone       = sectionVm.Phone;
                section.Email       = sectionVm.Email;

                db.Section.Update(section);
                db.Save();

                return(Json(sectionVm));
            }

            sectionVm.IsValid = false;
            sectionVm.Message = "Validation Failed!. Please try Again with valid data.";
            return(Json(sectionVm));
        }
Example #14
0
        public ActionResult Edit(SectionVm section)
        {
            if (ModelState.IsValid)
            {
                var model = Mapper.Map <SectionVm, Section>(section);
                model.SectionState = SectionState.Active;

                var customUrl =
                    _customUrlService.GetAll()
                    .FirstOrDefault(x => x.ContentId == section.Id && x.ContentType == ContentType.Section);

                if (customUrl == null && !string.IsNullOrEmpty(section.Path))
                {
                    customUrl = new CustomUrl();
                }

                if (customUrl != null && customUrl.Url != section.Path)
                {
                    if (!_customUrlService.IsUniquePath(section.Path))
                    {
                        ModelState.AddModelError("Path", "Путь не уникален");
                        return(View(section));
                    }

                    customUrl.Url         = section.Path;
                    customUrl.ContentType = ContentType.Section;
                    customUrl.ContentId   = section.Id;

                    _customUrlService.CreateOrUpdate(customUrl);
                }

                _sectionService.Update(model);
                //TODO: remove (temporary for output cache)
                MemoryCacheHelper.SectionsUpdateTime = DateTime.Now;

                return(RedirectToAction("Index"));
            }
            return(View(section));
        }
        public IActionResult SaveSection([Bind("SectionId,TournamentId,Name,PlayersPerTeam,Par,Gender")] SectionVm viewModel)
        {
            SectionVmValidator validator        = new SectionVmValidator();
            ValidationResult   validationResult = validator.Validate(viewModel);

            if (validationResult.IsValid)
            {
                _sectionManagement.UpdateSection(viewModel.Section());
            }
            else
            {
                foreach (ValidationFailure failure in validationResult.Errors)
                {
                    ModelState.AddModelError(failure.PropertyName,
                                             failure.ErrorMessage);
                }
            }

            viewModel.Tournament = _tournamentManagement.GetTournamentById(viewModel.TournamentId);
            viewModel.Teams      = _teamManagement.GetTeamsForSection(viewModel.SectionId);
            return(View("SectionAdminForm", viewModel));
        }
        public IActionResult Create(SectionVm sectionVm)
        {
            if (ModelState.IsValid)
            {
                Section section = new Section()
                {
                    Name        = sectionVm.Name,
                    Description = sectionVm.Description,
                    Phone       = sectionVm.Phone,
                    Email       = sectionVm.Email,
                    IsActive    = true,
                    IsDeleted   = false
                };

                db.Section.Add(section);
                db.Save();

                return(Json(sectionVm));
            }

            sectionVm.IsValid = false;
            sectionVm.Message = "Validation Failed!. Please try Again with valid data.";
            return(Json(sectionVm));
        }
Example #17
0
        public string GetEditionUrl(Guid secretkey)
        {
            var customer = _unitOfWork.CustomerRepository.GetBySecretKey(secretkey);

            Guid editionid = customer.EditionId.Value;

            //dir on webapi project where all editions zip files will be present.

            var dir = HttpContext.Current.Server.MapPath("~/Editions/");

            //dir of a edition

            var editionid_dir         = dir + editionid;
            var editition_modules_dir = editionid_dir + "//Modules";

            //dir where modules files are uploaded


            var modulesdir = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("~/Modules/"));

            if (!System.IO.Directory.Exists(editionid_dir))
            {
                System.IO.Directory.CreateDirectory(editionid_dir);
                System.IO.Directory.CreateDirectory(editition_modules_dir);
                var edition = _unitOfWork.EditionRepository.Get(editionid, true);


                EditionInfo edition_info = new EditionInfo();

                foreach (var section in edition.Sections)
                {
                    var sectionvm = new SectionVm();

                    sectionvm.Name = section.Name;

                    foreach (var module in section.Modules)
                    {
                        ModuleVm module_vm = new ModuleVm();

                        string mdouleFile = module.TypeName + ".dll";

                        module_vm.TypeName = mdouleFile;
                        module_vm.Name     = module.Name;

                        string mdouleFilepath      = System.IO.Path.Combine(modulesdir, mdouleFile);;
                        string destinationFilepath = System.IO.Path.Combine(editition_modules_dir, mdouleFile);;

                        if (System.IO.File.Exists(mdouleFilepath))
                        {
                            System.IO.File.Copy(mdouleFilepath, destinationFilepath, true);
                        }


                        sectionvm.Modules.Add(module_vm);
                    }
                    edition_info.Sections.Add(sectionvm);
                }

                //create customer modules  information json file.
                string startPath = editionid_dir;

                var json = JsonHelper.Serialize(edition_info);

                System.IO.File.WriteAllText(startPath + "//edition_info.json", json);


                string zipPath = dir + editionid + ".zip";

                ZipFile.CreateFromDirectory(startPath, zipPath);
            }

            string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";

            return(baseUrl + "Editions/" + editionid + ".zip");
        }
        public IActionResult Create()
        {
            SectionVm sectionVm = new SectionVm();

            return(PartialView("_CreateView", sectionVm));
        }