Exemplo n.º 1
0
        public async Task <IActionResult> Program(int?id = null)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage != PsSchedulingStage.RegistrationOpen)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var userId    = GetId(ClaimType.UserId);
            var performer = await _performerSchedulingService.GetPerformerByUserIdAsync(userId);

            if (performer == null)
            {
                return(RedirectToAction(nameof(Information)));
            }
            else if (!performer.SetSchedule)
            {
                return(RedirectToAction(nameof(Schedule)));
            }

            var ageGroups = await _performerSchedulingService.GetAgeGroupsAsync();

            var ageList = new SelectList(ageGroups, "Id", "Name");

            if (ageList.Count() == 1)
            {
                ageList.First().Selected = true;
            }

            var viewModel = new ProgramViewModel
            {
                AgeList               = ageList,
                MaxUploadMB           = MaxUploadMB,
                RegistrationCompleted = performer.RegistrationCompleted,
                SetupSupplementalText = settings.SetupSupplementalText
            };

            if (id.HasValue)
            {
                try
                {
                    var program = await _performerSchedulingService.GetProgramByIdAsync(id.Value,
                                                                                        includeAgeGroups : true);

                    viewModel.AgeSelection   = program.AgeGroups.Select(_ => _.Id).ToList();
                    viewModel.EditingProgram = true;
                    viewModel.Program        = program;
                }
                catch (GraException gex)
                {
                    ShowAlertDanger("Unable to view Program: ", gex);
                    return(RedirectToAction(nameof(Dashboard)));
                }
            }

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult EditProgram(int id, string language)
        {
            ChangingLanguageFunction(language);

            var program = _context.Programs.SingleOrDefault(p => p.Id == id);

            if (program == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ProgramViewModel
            {
                program = program,
                club    = _context.Clubs.ToList()
            };

            // Sends The Program Title to the editProgramForm using ViewBag
            ViewBag.EditedProgramName = program.Title;

            if (language.Equals("ar"))
            {
                return(View("~/Views/ArabicViews/ArabicProgram/EditProgramForm.cshtml", viewModel));
            }

            else
            {
                return(View("~/Views/EnglishViews/EnglishProgram/EditProgramForm.cshtml", viewModel));
            }
        }
Exemplo n.º 3
0
        public async Task <int> Update(ProgramViewModel program)
        {
            var programModel = program.Adapt <ProgramModel>();
            var result       = await _programFactory.Update(programModel);

            return(result);
        }
        public ActionResult Create(ProgramViewModel programViewModel)
        {
            Program           program   = programViewModel.Program;
            IEnumerable <int> courseIds = programViewModel.CourseIds;

            try
            {
                program = programService.Add(program);
                if (courseIds != null)
                {
                    foreach (int courseId in courseIds)
                    {
                        ProgramCourseAssociation programCourseAssociation = new ProgramCourseAssociation
                        {
                            ProgramId = program.Id,
                            CourseId  = courseId
                        };
                        programCourseAssociationService.Add(programCourseAssociation);
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(programViewModel));
            }
        }
Exemplo n.º 5
0
        private void HandleUpdatesForStopStartProgram(ProgressResponse response, ProgramViewModel program, bool start)
        {
            MainThreadUtility.InvokeOnMain(() =>
            {
                if (response != null)
                {
                    DataCache.AddCommandProgress(new CommandProgress(CommandType.StartPrograms, response.Body, new string[] { program.Id }));

                    if (response.IsFinal)
                    {
                        Action resetProgram = () =>
                        {
                            program.Starting = false;
                            //ServiceContainer.DeviceService.RequestDevice(this.Device.Device);
                        };

                        if (response.IsSuccessful)
                        {
                            //AlertUtility.ShowProgressResponse("Stop/Start Program " + program.Id, response);
                            this.RegisterForAsyncUpdate(resetProgram, 5000);
                        }
                        else
                        {
                            this.RegisterForAsyncUpdate(resetProgram);

                            if ((bool)!response?.IsReconnectResponse && (bool)!response?.IsServerDownResponse)
                            {
                                AlertUtility.ShowAppError(response?.ErrorBody);
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 6
0
 public ActionResult Edit(ProgramViewModel model)
 {
     try
     {
         Program program = new Program()
         {
             Id = model.Id, Address = model.Address, Budget = model.Budget, CityId = model.CityId, Date = DateTime.ParseExact(model.Date, "mm-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture), EmploymentDept = model.EmploymentDept, Title = model.Title, Method = model.Method, Participants = model.Participants, SourceOfFunds = model.SourceOfFunds, StateId = model.StateId, Type = model.Type
         };
         var response = _programLogic.Edit(program);
         if (response.IsError == true)
         {
             foreach (var item in response.ErrorCodes)
             {
                 ModelState.AddModelError(string.Empty, item);
             }
             PrepareSelectList(model.StateId, model.CityId);
             return(View(model));
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        private void LpViewModel_UploadClickEvent(LocalProgramListViewModel local, ProgramViewModel obj)
        {
            Stream stream = default;

            using (var fileStream = new FileStream(System.IO.Path.Combine(local.Path, obj.Name), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                byte[] bytes = new byte[fileStream.Length];
                fileStream.Read(bytes, 0, bytes.Length);
                fileStream.Close();
                stream = new MemoryStream(bytes);
            }

            Task.Factory.StartNew(new Action(() =>
            {
                EventBus.Default.TriggerAsync(new UpLoadProgramClientEventData
                {
                    FileParameter = new Common.FileParameter(stream, obj.Name),
                    ConnectId     = local.ConnectId,
                    FileHashCode  = obj.FileHash
                });
            }));
            modalControl = new UpLoadLocalProgramControl(local.Path, obj.FileHash);
            modalControl.ProgramUploadEvent += Modal_ProgramUploadEvent;
            new PopupWindow(modalControl, 900, 590, "上传本地程序").ShowDialog();
            modalControl = null;
        }
Exemplo n.º 8
0
 private void StopStartProgram(ProgramViewModel program, bool start)
 {
     MainThreadUtility.InvokeOnMain(() =>
     {
         this.NavigateTo(ProgramRepeatSelectViewController.CreateInstance(this.Device?.Id, start, program));
     });
 }
        private ProgramViewModel GetProgramViewModel(FitnessProgram program)
        {
            var vm = new ProgramViewModel
            {
                TemplateViewModel = new TemplateViewModel(program.Template),
                Id                = program.Id,
                Created           = program.Created,
                ApplicationIdNull = program.ApplicationUserId == null
            };
            var exerciseList = _db.Exercises.ToList();

            foreach (WorkoutViewModel workoutViewModel in vm.TemplateViewModel.Workouts)
            {
                foreach (MuscleExerciseViewModel muscleExerciseViewModel in workoutViewModel.WorkoutHistoryViewModel
                         .MuscleExerciseViewModels)
                {
                    muscleExerciseViewModel.ExerciseList = exerciseList
                                                           .Where(x => x.MuscleType == muscleExerciseViewModel.MuscleType).ToList();
                    foreach (ExerciseViewModel exerciseViewModel in muscleExerciseViewModel.Exercises)
                    {
                        var linkId = _db.YoutubeVideoQueries.SingleOrDefault(x => x.Query == exerciseViewModel.Name)
                                     ?.LinkId;
                        exerciseViewModel.YoutubeVideoId = linkId;
                    }
                }
            }

            return(vm);
        }
Exemplo n.º 10
0
        public JsonResult Search(ProgramViewModel model)
        {
            JSonResult objResult = new JSonResult();

            try
            {
                List <MProgramName> entList = new List <MProgramName>();

                entList = new WebApiProgram().GetProgramNames();

                model.ProjectCode = model.ProjectCode ?? "";
                model.ProgramName = model.ProgramName ?? "";

                if (!model.ProjectCode.Equals(""))
                {
                    entList = entList.Where(p => p.ProjectCode.Contains(model.ProjectCode)).ToList();
                }

                if (!model.ProgramName.Equals(""))
                {
                    entList = entList.Where(p => p.ProgramName.Contains(model.ProgramName)).ToList();
                }

                objResult.data = entList;
            }
            catch (Exception)
            {
                objResult.data    = null;
                objResult.isError = true;
                objResult.message = string.Format(MessageResource.ControllerGetExceptionMessage, "Program Names");
            }

            return(Json(objResult));
        }
Exemplo n.º 11
0
        public ActionResult Delete(ProgramViewModel model)
        {
            try
            {
                var response = _programLogic.Delete(model.Id);;
                if (response.IsError == true)
                {
                    foreach (var error in response.ErrorCodes)
                    {
                        ModelState.AddModelError(string.Empty, error);
                    }

                    var item = _programLogic.GetById(model.Id);
                    ProgramViewModel program = new ProgramViewModel()
                    {
                        Id = item.Id, Address = item.Address, Budget = item.Budget, CityId = item.CityId, CityName = item.City.Title, Date = item.Date.ToString("mm-dd-yyyy"), EmploymentDept = item.EmploymentDept, Title = item.Title, Method = item.Method, Participants = item.Participants, SourceOfFunds = item.SourceOfFunds, StateId = item.StateId, StateName = item.State.Title, Type = item.Type
                    };
                    return(View(program));
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 12
0
        public void ReadXml(XmlReader reader)
        {
            if (reader.ReadToDescendant(@"RecentPrograms"))
            {
                reader.ReadStartElement();
                while (reader.Name == @"TVCProgram")
                {
                    string fullpath       = reader.GetAttribute(@"ProgramPath");
                    string isOpenedString = reader.GetAttribute(@"ProgramIsOpened");
                    if (!string.IsNullOrEmpty(fullpath) && !string.IsNullOrEmpty(isOpenedString))
                    {
                        bool wasOpened = bool.Parse(isOpenedString);

                        if (wasOpened)
                        {
                            OpenProgram(fullpath);
                        }
                        else
                        {
                            ProgramViewModel program = ProgramViewModel.Create(fullpath, this, TvcStudioSettings);
                            RecentPrograms.Add(program);
                        }
                    }
                    reader.ReadStartElement();
                }
            }
        }
Exemplo n.º 13
0
 public BasicDocumentViewModel(string programFullPath, ProgramViewModel program, TvcStudioSettings settings) : base(programFullPath, settings)
 {
     Program            = program;
     IsReadOny          = false;
     CollapseAllCommand = new RelayCommand(o => { }, o => false);
     ExpandAllCommand   = new RelayCommand(o => { }, o => false);
 }
Exemplo n.º 14
0
        public void OpenProgram(string fullpath)
        {
            var openedProgram = OpenedDocuments.FirstOrDefault(op => op.ProgramFullPath == fullpath);

            if (openedProgram != null)
            {
                DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram));
                return;
            }

            var programforOpening =
                RecentPrograms.FirstOrDefault(p => p.ProgramFullPath == fullpath);

            if (programforOpening == null)
            {
                programforOpening = ProgramViewModel.Create(fullpath, this, TvcStudioSettings);
                RecentPrograms.Add(programforOpening);
            }

            if (programforOpening.ProgramState == ProgramState.NotFound)
            {
                TraceEngine.TraceError($"{programforOpening.ProgramFullPath} beolvasása sikertelen, a file nem található!");
                return;
            }

            openedProgram = programforOpening.GetDocumentViewModel();
            openedProgram.DocumentClosedEvent += OnDocumentClose;
            OpenedDocuments.Add(openedProgram);
            programforOpening.ProgramState = ProgramState.Opened;
            DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram));
        }
Exemplo n.º 15
0
        public IActionResult AddProgram(ProgramViewModel model)
        {
            /*double cost;
             * string type = model.cost_type.ToString();*/

            if (ModelState.IsValid)
            {
                //check the cost_type to verify the cost of the program
                //paid option = 300K

                //Income_Sharing = 1M
                //switch (model.cost_type)
                //{
                //    case Models.Students.addmissionType.Paid:
                //        cost = 300000;
                //        break;
                //    case Models.Students.addmissionType.Income_Sharing:
                //        cost = 1000000;
                //        break;
                //    default:
                //        break;
                //}

                Programme programme = new Programme()
                {
                    Program_Name = model.ProgramName,
                    Cost         = model.cost,
                    Duration     = model.duration
                };
                _programRepo.AddProgramme(programme);
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemplo n.º 16
0
        public void UpdateSubProgramTest()
        {
            bool   pass              = true;
            string ValidLOOPString   = @"LOOP 0,0,0 
END_LOOP";
            string InvalidLOOPString = @"IF 0,0,0 
ELSE
END_IF";

            try
            {
                HLProgram        hpValid   = new HLProgram(ValidLOOPString);
                HLProgram        hpInvalid = new HLProgram(InvalidLOOPString);
                ProgramViewModel pvm       = new ProgramViewModel(new HLProgram());

                pvm.InsertSubProgram(0, hpInvalid);
                pvm.UpdateSubProgram(0, hpValid);
                pass = true;
            }
            catch (InstructionException ex)
            {
                Console.WriteLine(ex + ": Invalid");
                pass = false;
            }
            Assert.IsTrue(pass);
        }
        //Assignment 1
        public string ProcessProgramName()
        {
            FreeWheelDBEntities     context = new FreeWheelDBEntities();
            List <ProgramViewModel> result  = new List <ProgramViewModel>();
            string delimiter = "'";
            string resultStr = "";

            var obj = context.PROGRAMs.Select(u => u).OrderBy(i => i.PROGRAM_NAME);

            string           results = null;
            ProgramViewModel model   = null;

            if (obj != null && obj.Count() > 0)
            {
                foreach (var data in obj)
                {
                    model = new ProgramViewModel();

                    model.programName = data.PROGRAM_NAME;


                    result.Add(model);
                }
            }


            foreach (ProgramViewModel data in result)
            {
                string tempProgramName = data.programName;

                resultStr = (resultStr + delimiter + tempProgramName.Replace("'", "\"") +
                             delimiter + ", ");
            }
            return(resultStr.Remove(resultStr.Length - 2));
        }
        public HttpResponseMessage Post([FromBody] ProgramViewModel program)
        {
            if (ModelState.IsValid)
            {
                var userId       = this.User.FindFirstValue(ClaimTypes.Name);
                var tempPrograms = AutoMapper.Mapper.Map <AgileClassRoom.Models.Program>(program);
                _program.InsertProgram(tempPrograms);

                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                };

                return(response);
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };

                return(response);
            }
        }
Exemplo n.º 19
0
        public ActionResult SaveReqPrg(Program program, string language)
        {
            ChangingLanguageFunction(language);

            if (language.Equals("ar"))
            {
                if (!ModelState.IsValid)
                {
                    var viewModels = new ProgramViewModel()
                    {
                        program = new Program(),
                        club    = _context.Clubs.ToList()
                    };

                    return(View("~/Views/ArabicViews/ArabicProgram/RequestProgramForm.cshtml", viewModels));
                }
            }

            else
            {
                if (!ModelState.IsValid)
                {
                    var viewModels = new ProgramViewModel()
                    {
                        program = new Program(),
                        club    = _context.Clubs.ToList()
                    };

                    return(View("~/Views/EnglishViews/EnglishProgram/RequestProgramForm.cshtml", viewModels));
                }
            }

            // To retrieve a program

            if (program.Id == 0)
            {
                _context.Programs.Add(program);
                // Sends the RequestProgramSuccessMessage to another action using the TempData
                TempData["RequestProgramSuccessMessage"] = 1;
            }

            else
            {
                var programInDb = _context.Programs.Single(p => p.Id == program.Id);
                programInDb.Title                = program.Title;
                programInDb.Time                 = program.Time;
                programInDb.StartDate            = program.StartDate;
                programInDb.EndDate              = program.EndDate;
                programInDb.MaximumStudentNumber = program.MaximumStudentNumber;
                programInDb.ClubId               = program.ClubId;
                programInDb.Description          = program.Description;
            }

            /* This exception will never occur because program id
             * is auto generated by the database */

            _context.SaveChanges();
            return(RedirectToAction("RequestedProgramsClubCor", "Program"));
        }
Exemplo n.º 20
0
        public void GetHLProgramTest()
        {
            HLProgram        hp  = new HLProgram();
            ProgramViewModel pvm = new ProgramViewModel(new HLProgram());

            hp = pvm.GetHLProgram();
            Assert.IsNotNull(hp);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes a new Instance of ProgramList
        /// </summary>
        public ProgramList()
        {
            InitializeComponent();

            this.Loaded += ListView1_Loaded;

            pvm = new ProgramViewModel(new HLProgram());
        }
Exemplo n.º 22
0
        public ActionResult Create()
        {
            ProgramViewModel viewModel = new ProgramViewModel();

            viewModel.Program = new Program();
            viewModel.Schools = schools.Collection();
            return(View(viewModel));
        }
Exemplo n.º 23
0
 public IActionResult Create(ProgramViewModel model)
 {
     if (ModelState.IsValid)
     {
         var createdProgram = programManager.AddProgramData(model);
         return(RedirectToAction("details", new { id = createdProgram.ID }));
     }
     return(View("CreateProgram", model));
 }
Exemplo n.º 24
0
        public void GetSubProgramTest()
        {
            ProgramViewModel pvm = new ProgramViewModel(new HLProgram());

            pvm.InsertInstruction(0, Instruction.CreatDefaultFromOpcode(Instruction.DRIVE));
            HLProgram hp = pvm.GetSubProgram(0);

            Assert.IsNull(hp);
        }
Exemplo n.º 25
0
 public ProgramViewModel GenerateView()
 {
     ProgramViewModel view = new ProgramViewModel()
     {
         ListOfFilms = AllFilm(),
         ListOfSeries = AllSeries()
     };
     return view;
 }
Exemplo n.º 26
0
        // GET: Instructor/Details/5
        public ActionResult Details(int id)
        {
            var item = _programLogic.GetById(id);
            ProgramViewModel instructor = new ProgramViewModel()
            {
                Id = item.Id, Address = item.Address, Budget = item.Budget, CityId = item.CityId, CityName = item.City.Title, Date = item.Date.ToString("mm-dd-yyyy"), EmploymentDept = item.EmploymentDept, Title = item.Title, Method = item.Method, Participants = item.Participants, SourceOfFunds = item.SourceOfFunds, StateId = item.StateId, StateName = item.State.Title, Type = item.Type
            };

            return(View(instructor));
        }
Exemplo n.º 27
0
        public IActionResult Edit(ProgramViewModel model)
        {
            if (ModelState.IsValid)
            {
                var programViewModel = programManager.Update(model);
                return(RedirectToAction("details", new { id = programViewModel.ID }));
            }

            return(View(model));
        }
Exemplo n.º 28
0
        public ActionResult Editar(string id)
        {
            ProgramBL oBL    = new ProgramBL();
            int       pIntID = 0;

            int.TryParse(id, out pIntID);
            ProgramViewModel pProgramViewModel = oBL.Obtener(pIntID);

            return(View(pProgramViewModel));
        }
Exemplo n.º 29
0
        public void CanCreateProgram()
        {
            var request          = new DataSourceRequest();
            var programViewModel = new ProgramViewModel {
                ProgramID = 1, ProgramName = "PSNP", Description = "PSNP Program"
            };
            var result = _programController.Program_Create(request, programViewModel);

            //Assert
            Assert.IsInstanceOf <JsonResult>(result);
        }
        // GET: Program/Create
        public ActionResult Create()
        {
            ProgramViewModel programViewModel = new ProgramViewModel
            {
                Program     = new Program(),
                Departments = departmentService.GetAll(),
                Courses     = courseService.GetAll()
            };

            return(View(programViewModel));
        }