public string addProgramme(Programme m)
    {
        cm.CommandText = "Insert into Programme(Programme_Name,Category_idCategory,Description,Fee,A/L_results_criteria,School_idSchool,Accredited_By_idAccredited_By) values(@a,@b,@c,@d,@e,@f,@g)";

        cm.Parameters.AddWithValue("a", m.Programme_Name);
        cm.Parameters.AddWithValue("b", m.Category_idCategory);
        cm.Parameters.AddWithValue("c", m.Description);
        cm.Parameters.AddWithValue("d", m.Fee);
        cm.Parameters.AddWithValue("e", m.Al_results_criteria);
        cm.Parameters.AddWithValue("f", m.School_idSchool);
        cm.Parameters.AddWithValue("g", m.Accredited_By_idAccredited_By);

        return db.InsertData(cm);
    }
        public void DocGetConfiguration(OXODoc currentDoc)
        {
            Programme retVal = new Programme();

            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@p_doc_id", currentDoc.Id, dbType: DbType.Int32);
                    using (var multi = conn.QueryMultiple("dbo.OXO_Doc_GetConfiguration", para, commandType: CommandType.StoredProcedure))
                    {
                        currentDoc.AllBodies        = multi.Read <ModelBody>().ToList();
                        currentDoc.AllEngines       = multi.Read <ModelEngine>().ToList();
                        currentDoc.AllTransmissions = multi.Read <ModelTransmission>().ToList();
                        currentDoc.AllTrims         = multi.Read <ModelTrim>().ToList();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }
        }
Example #3
0
 public Student()
 {
     //ExamEnrollments = new ExamEnrollment(); //// this code create ExamEnrollment  {} includes all attributes from ExamEnrollment class
     Programmes     = new Programme();
     ExamEnrollment = new List <ExamEnrollmentViewModel>();
     //Enrollment = new List<EnrollmentViewModel>();
 }
        public Programme Delete(Programme obj)
        {
            obj.ValidationErrors.Clear();
            try
            {
                if (Exists(obj.ObjId))
                {
                    obj = CheckDelete(obj);
                    if (obj.ValidationErrors.Count > 0)
                    {
                        return(obj);
                    }

                    if (ExcuteStatement("DELETE FROM programme_tab WHERE ObjId=" + obj.ObjId))
                    {
                        return(obj);
                    }
                    else
                    {
                        obj.ValidationErrors.Add("Error While deleting..");
                        return(obj);
                    };
                }
                else
                {
                    throw new Exception("Object has been removed by another user.");
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public void Add(Programme item)
        {
            lock (_session)
            {
                if (item.Id == Guid.Empty)
                {
                    item.Id = Guid.NewGuid();
                }

                _session.Store(item);

                var pd = _session.Query <ProgrammeDictionary>()
                         .FirstOrDefault(x => x.ExternalReference == item.ExternalReference);

                var isNew = false;
                if (pd is null)
                {
                    pd = new ProgrammeDictionary {
                        ExternalReference = item.ExternalReference
                    };
                    isNew = true;
                }

                pd.ProgrammeName  = item.ProgrammeName;
                pd.Description    = item.Description;
                pd.Classification = item.Classification;

                if (isNew)
                {
                    _session.Store(pd);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Permet de construire l'interface graphique (boutons, menu, texte, dessins)
        /// </summary>
        public Introduction(Programme p_programme) : base(new ÉtatIntroduction(p_programme))
        {
            Fond = Constantes.Fond;

            m_logoIntro = new List <Texte>();

            ConstruireLogo();

            Texte texteDemarrer = new Texte(new Coordonnée(CentreX, 3 * QuartY + 140), "Vous pouvez appuyer sur Enter pour démarrer ou ESC pour quitter", Blanc, 15);

            AjouterÉlément(texteDemarrer);

            Bouton btnDémarrer = new Bouton(new Coordonnée(CentreX, 3 * QuartY + 60),
                                            new Dimension(200, 100), PacMan, JauneFonce,
                                            "Démarrer", 30, ÉtatProgramme.TypeActionBouton.Information);

            AjouterBouton(btnDémarrer);

            m_déplacement = Déplacement.Droite;

            Partie.Instance.Pacman.MettreAJourCoordonnée(new Coordonnée(-200, CentreY - 90));
            Partie.Instance.Blinky.MettreAJourCoordonnée(new Coordonnée(-250, CentreY - 90));
            Partie.Instance.Pinky.MettreAJourCoordonnée(new Coordonnée(-275, CentreY - 90));
            Partie.Instance.Inky.MettreAJourCoordonnée(new Coordonnée(-300, CentreY - 90));
            Partie.Instance.Clyde.MettreAJourCoordonnée(new Coordonnée(-325, CentreY - 90));
        }
        public async Task <IActionResult> PutProgramme(int id, Programme programme)
        {
            if (id != programme.Id)
            {
                return(BadRequest());
            }

            _context.Entry(programme).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProgrammeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Programme> > PostProgramme(Programme programme)
        {
            _context.Programme.Add(programme);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProgramme", new { id = programme.Id }, programme));
        }
        public async Task <IActionResult> Edit(string id, [Bind("ProgrammeID,ProgrammeName,ProgrammeDescription,ProgrammeQQILevel,ProgrammeCredits,ProgrammeCost")] Programme programme)
        {
            if (id != programme.ProgrammeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    programmeRepository.Update(programme);
                    await programmeRepository.SaveChangesAsync();

                    return(RedirectToAction("Details", new { id = programme.ProgrammeID }));
                }
                catch (DataAccessException e)
                {
                    if (!ProgrammeExists(programme.ProgrammeID))
                    {
                        return(NotFound());
                    }
                    ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e);
                    return(RedirectToAction("Unknown", "Error"));
                }
                catch (Exception e)
                {
                    ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e);
                    return(RedirectToAction("Unknown", "Error"));
                }
            }
            return(View(programme));
        }
        public async Task <IActionResult> Create([Bind("ProgrammeID,ProgrammeName,ProgrammeDescription,ProgrammeQQILevel,ProgrammeCredits,ProgrammeCost")] Programme programme)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await programmeRepository.AddAsync(programme);

                    await programmeRepository.SaveChangesAsync();

                    ViewBag.SuccessMsg = "Programme Created Successfully";

                    var programmeDetails = await programmeRepository.FindByIdAsync(programme.ProgrammeID);

                    ModelState.Clear();

                    return(RedirectToAction("Details", new { id = programme.ProgrammeID }));
                }
                return(View(programme));
            }
            catch (DataAccessException e)
            {
                ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e);
                return(RedirectToAction("Unknown", "Error"));
            }
            catch (Exception e)
            {
                ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e);
                return(RedirectToAction("Unknown", "Error"));
            }
        }
        private static void ValidateWithSpotRestrictions(
            SmoothBreak theSmoothBreak,
            Programme programme,
            SalesArea salesArea,
            IReadOnlyCollection <Spot> spotsForBreak,
            SmoothResources smoothResources,
            IReadOnlyCollection <Break> breaksBeingSmoothed,
            IReadOnlyCollection <Programme> scheduleProgrammes,
            SmoothFailureMessagesForSpotsCollection result)
        {
            var anyRestrictions = CheckRestrictionsForSpots(
                spotsForBreak,
                theSmoothBreak.TheBreak,
                programme,
                salesArea,
                smoothResources,
                breaksBeingSmoothed,
                scheduleProgrammes);

            foreach (var item in anyRestrictions)
            {
                foreach (var failure in item.Value.Failures)
                {
                    result.Add(item.Key, failure.FailureMessage, failure.Restriction);
                }
            }
        }
Example #12
0
        public Jeu(Programme p_programme) : base(new ÉtatJeu(p_programme))
        {
            m_vies = new List <ObjetDessinable>();

            Fond = Constantes.Fond;

            Texte oneUp = new Texte(new Coordonnée(QuartX, 25), "1UP", Lettres, 25);

            m_pointage = new Texte(new Coordonnée(QuartX, 50), Partie.Instance.Score.ToString("D3"), Lettres, 25);

            Texte record = new Texte(new Coordonnée(3 * QuartX, 25), "Record", Lettres, 25);

            m_record = new Texte(new Coordonnée(3 * QuartX, 50), Partie.Instance.Record.ToString("D3"), Lettres, 25);

            Texte niveau = new Texte(new Coordonnée(3 * QuartX + 100, 25), "Niveau", Lettres, 25);

            m_niveau = new Texte(new Coordonnée(3 * QuartX + 100, 50), Partie.Instance.Niveau.ToString("D3"), Lettres, 25);

            AjouterEnsembleÉléments(new ObjetDessinable[] { oneUp, m_pointage, record, m_record, niveau, m_niveau });

            Bouton aide = new Bouton(new Coordonnée(CentreX, 37), new Dimension(200, 55),
                                     PacMan, JauneFonce, "AIDE (F1)", 30, ÉtatProgramme.TypeActionBouton.Pause);

            AjouterBouton(aide);

            MettreAJourVies();
        }
Example #13
0
        public void TwoSponsorshipRestrictionsItems_ForGivenDurationReturnsOneResult(
            string dayPartStartTime, string dayPartEndTime)
        {
            // Arrange
            ImmutableList <Sponsorship> listToFilter =
                CreateSponsorshipForDurationsWithProgrammeRestrictionLevel(
                    TimeSpan.Parse(dayPartStartTime),
                    TimeSpan.Parse(dayPartEndTime));

            listToFilter[0].SponsoredItems[1].SponsorshipItems.Last().DayParts =
                new List <SponsoredDayPart>()
            {
                new SponsoredDayPart()
                {
                    DaysOfWeek = new string[] {
                        "Sun", "Mon", "Tue", "Wed", "Thu",
                    },
                    StartTime = new TimeSpan(),
                    EndTime   = new TimeSpan()
                },
            };
            Programme programme = CreateProgrammeForDuration(new DateTime(2020, 4, 21, 17, 0, 0));
            var       filter    = new SponsorshipRestrictionFilterService(listToFilter);

            // Act
            var result = filter.Filter(programme);

            // Assert
            _ = result.Should().ContainSingle(becauseArgs: null);
            _ = result[0].SponsoredItems.Should().ContainSingle(becauseArgs: null);
            _ = result[0].SponsoredItems[0].SponsorshipItems.Should().ContainSingle(becauseArgs: null);
        }
Example #14
0
 public RegistrationFeeModel()
 {
     Level              = new Level();
     Department         = new Department();
     RegistrationPeriod = new RegistrationPeriod();
     Programme          = new Programme();
 }
Example #15
0
        public async Task<IHttpActionResult> PostProgramme(Programme programme)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Programmes.Add(programme);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ProgrammeExists(programme.ProgrammeCode))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return Ok(programme);
        }
Example #16
0
        public async Task<IHttpActionResult> PutProgramme(string name, Programme programme)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (name != programme.ProgrammeCode)
            {
                return BadRequest();
            }

            db.Entry(programme).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProgrammeExists(name))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task <IActionResult> AssignProgramme(int clientId, ProgrammeForListDto programmeForListDto)
        {
            // if (clientId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //     return Unauthorized();

            var clientFromRepo = await _repo.GetClient(clientId);

            var programmeForReturn = new Programme
            {
                ProgrammeName = programmeForListDto.ProgrammeName,
                ProgrammeType = programmeForListDto.ProgrammeType,
                Description   = programmeForListDto.Description,
                RelatedLink   = programmeForListDto.RelatedLink,
                SessionTime   = programmeForListDto.SessionTime,
                ClientId      = clientId
            };

            clientFromRepo.Programmes.Add(programmeForReturn);

            if (await _repo.SaveAll())
            {
                return(StatusCode(201));
            }
            return(BadRequest("프로그램 등록에 실패하였습니다"));
        }
        public Programme Get(int ObjId)
        {
            String    query = "SELECT ObjId,ObjVersion,ProgrammeName FROM programme_tab Where Objid=" + ObjId;
            Programme obj   = new Programme();

            if (this.OpenConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    obj.ObjId      = int.Parse(dataReader["ObjId"].ToString());
                    obj.ObjVersion = int.Parse(dataReader["ObjVersion"].ToString());

                    obj.ProgrammeName = dataReader["ProgrammeName"].ToString();
                }
                dataReader.Close();
                this.CloseConnection();
                return(obj);
            }
            else
            {
                return(obj);
            }
        }
        public void MoveToSaveFolderSubfolders()
        {
            string tempBase = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(tempBase);
            string sourceFile = Path.GetTempFileName();

            var prog = new Programme();

            prog.Name = "PN1";

            var episode = new Episode();

            episode.Name = "EN";

            Assert.Equal(
                Path.Combine(tempBase, "PN1", "EN" + ".mp3"),
                Download.MoveToSaveFolder(@"%progname%\%epname%", prog, episode, tempBase, "mp3", sourceFile));

            Assert.True(Directory.Exists(Path.Combine(tempBase, "PN1")));

            prog.Name  = "PN2";
            sourceFile = Path.GetTempFileName();

            Assert.Equal(
                Path.Combine(tempBase, "PN2", "EN" + ".mp3"),
                Download.MoveToSaveFolder(@"%progname%/%epname%", prog, episode, tempBase, "mp3", sourceFile));

            Assert.True(Directory.Exists(Path.Combine(tempBase, "PN2")));

            Directory.Delete(tempBase, true);
        }
        private Programme Add(Programme obj)
        {
            obj.ValidationErrors.Clear();

            try
            {
                if (Exists(obj))
                {
                    obj.ValidationErrors.Add("Programme is already Exist.");
                    return(obj);
                }
                else
                {
                    String query = "INSERT INTO programme_tab (ProgrammeName,ObjVersion)VALUES(" +
                                   "'" + obj.ProgrammeName + "'," +
                                   "'0')";

                    if (ExcuteStatement(query))
                    {
                        obj.ObjId = Get(obj.ProgrammeName).ObjId;
                        return(obj);
                    }
                    else
                    {
                        obj.ValidationErrors.Add("Error While adding..");
                        return(obj);
                    };
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #21
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (MatricNo.Length != 0)
            {
                hash ^= MatricNo.GetHashCode();
            }
            if (School.Length != 0)
            {
                hash ^= School.GetHashCode();
            }
            if (BloodGroup.Length != 0)
            {
                hash ^= BloodGroup.GetHashCode();
            }
            if (Programme.Length != 0)
            {
                hash ^= Programme.GetHashCode();
            }
            if (ProfilePicture.Length != 0)
            {
                hash ^= ProfilePicture.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public List <Programme> GetAll()
        {
            string query = "SELECT ObjId,ObjVersion,ProgrammeName FROM programme_tab ORDER BY ObjId DESC";

            List <Programme> lst = new List <Programme>();
            Programme        obj;

            if (this.OpenConnection() == true)
            {
                //Create Command
                MySqlCommand    cmd        = new MySqlCommand(query, connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    obj               = new Programme();
                    obj.ObjId         = int.Parse(dataReader["ObjId"].ToString());
                    obj.ObjVersion    = int.Parse(dataReader["ObjVersion"].ToString());
                    obj.ProgrammeName = dataReader["ProgrammeName"].ToString();
                    lst.Add(obj);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(lst);
            }
            else
            {
                return(lst);
            }
        }
Example #23
0
        public async Task <IActionResult> Create(Programme programme)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound(programme));
            }

            var identity = (ClaimsIdentity)this.User.Identity;
            var claim    = identity.FindFirst(ClaimTypes.NameIdentifier);
            var team     = await _context.TeamMembers.FirstOrDefaultAsync(t => t.UserID == claim.Value);

            programme.CreatedAt = DateTime.Now;
            programme.TeamID    = team.TeamID;

            try
            {
                _context.Programmes.Add(programme);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e + ": An error occurred.");
            }

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Duration,Equipment,Description,Price")] Programme programme)
        {
            if (id != programme.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(programme);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgrammeExists(programme.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(programme));
        }
 public bool DeleteProgramme(Programme programme)
 {
     using (var _userImmovableAssetManagementPlan = new UserImmovableAssetManagementPlanRepository(_appSettings))
     {
         return(_userImmovableAssetManagementPlan.DeleteProgramme(programme));
     }
 }
        public IHttpActionResult PutProgramme(int id, Programme programme)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != programme.Programme_Id)
            {
                return(BadRequest());
            }

            db.Entry(programme).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProgrammeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #27
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,StartDate,EndDate,SpeakerId,RoomId,AttendanceCode,Type")] Programme programme)
        {
            if (id != programme.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(programme);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgrammeExists(programme.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoomId"]    = new SelectList(_context.Room, "Id", "Name", programme.RoomId);
            ViewData["SpeakerId"] = new SelectList(_context.Speaker, "Id", "Country", programme.SpeakerId);
            return(View(programme));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProgrammeId,Title,Description,Image,Length,CategoryId")] Programme programme)
        {
            if (id != programme.ProgrammeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(programme);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgrammeExists(programme.ProgrammeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryId", programme.CategoryId);
            return(View(programme));
        }
        public async Task <IActionResult> OnGetJsonAsync(string academicYear, int plan, string course)
        {
            int planRevisionID = 0;

            if (plan >= 1)
            {
                planRevisionID = plan;
            }
            else
            {
                planRevisionID = int.Parse(_configuration.GetSection("ProResource")["PlanRevisionID"]);
            }

            string CurrentAcademicYear = await AcademicYearFunctions.GetAcademicYear(academicYear, _context);

            Programme = (await _context.Programme
                         .FromSqlInterpolated($"EXEC SPR_ETG_ProgrammeData @AcademicYear={CurrentAcademicYear}, @PlanRevisionID={planRevisionID}, @Course={course}")
                         .ToListAsync())
                        .FirstOrDefault();

            var collectionWrapper = new
            {
                programme = Programme
            };

            return(new JsonResult(collectionWrapper));
        }
        public async Task <IActionResult> OnGetAsync(string academicYear, int plan, string course)
        {
            if (course == null)
            {
                return(NotFound());
            }

            int planRevisionID = 0;

            if (plan >= 1)
            {
                planRevisionID = plan;
            }
            else
            {
                planRevisionID = int.Parse(_configuration.GetSection("ProResource")["PlanRevisionID"]);
            }

            string CurrentAcademicYear = await AcademicYearFunctions.GetAcademicYear(academicYear, _context);

            Programme = (await _context.Programme
                         .FromSqlInterpolated($"EXEC SPR_ETG_ProgrammeData @AcademicYear={CurrentAcademicYear}, @PlanRevisionID={planRevisionID}, @Course={course}")
                         .ToListAsync())
                        .FirstOrDefault();

            if (Programme == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #31
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());
        }
        public Programme Programme(ModelTrim trim)
        {
            ProgrammeDataStore ds = new ProgrammeDataStore("system");
            Programme retVal = new Programme();

            retVal = ds.ProgrammeGet(trim.ProgrammeId);
            return retVal;
        }
        public async Task<IEnumerable<TakeRateSummary>> ListAvailableImports(VehicleFilter filter, Programme forProgramme)
        {
            var imports = await Task.FromResult(_volumeDataStore
                            .FdpTakeRateHeaderGetManyByUsername(new TakeRateFilter()
                            {
                                ProgrammeId = filter.ProgrammeId,
                                Gateway = filter.Gateway
                            })
                            .CurrentPage
                            .ToList());

            foreach (var import in imports) {
                //import.Vehicle = (Vehicle)HydrateVehicleFromProgramme(forProgramme);
                //import.Vehicle.Gateway = import.Gateway;
            }

            return imports;
        }
 public static void PopulateConfiguration(Programme programme)
 {
     var ds = new ProgrammeDataStore("system");
     var obj = ds.ProgrammeGetConfiguration(programme.Id);
     if (obj == null) return;
     programme.Id = obj.Id;
     programme.VehicleName = obj.VehicleName;
     programme.VehicleAKA = obj.VehicleAKA;
     programme.VehicleMake = obj.VehicleMake;
     programme.VehicleDisplayFormat = obj.VehicleDisplayFormat;
     programme.ModelYear = obj.ModelYear;
     programme.PS = obj.PS;
     programme.J1 = obj.J1;
     programme.Notes = obj.Notes;
     programme.ProductManager = obj.ProductManager;
     programme.RSGUID = obj.RSGUID;
     programme.Active = obj.Active;
     programme.AllBodies = obj.AllBodies;
     programme.AllEngines = obj.AllEngines;
     programme.AllTransmissions = obj.AllTransmissions;
     programme.AllTrims = obj.AllTrims;
 }
        public Programme ProgrammeGetConfiguration(int id)
        {
            var retVal = new Programme();
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@p_Id", id, DbType.Int32);
                    using (var multi = conn.QueryMultiple("dbo.OXO_Programme_GetConfiguration", para, commandType: CommandType.StoredProcedure))
                    {
                        retVal = multi.Read<Programme>().FirstOrDefault();
                        retVal.AllBodies = multi.Read<ModelBody>().ToList();
                        retVal.AllEngines = multi.Read<ModelEngine>().ToList();
                        retVal.AllTransmissions = multi.Read<ModelTransmission>().ToList();
                        retVal.AllTrims = multi.Read<ModelTrim>().ToList();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return retVal;
        }
        public bool ProgrammeSave(Programme obj)
        {
            var retVal = true;
            var procName = (obj.IsNew ? "dbo.OXO_Programme_New" : "dbo.OXO_Programme_Edit");

            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    obj.Save(CurrentCDSID);
 
                    var para = new DynamicParameters();

                   // para.Add("@p_AKA", obj.AKA, dbType: DbType.String, size: 500);
                    para.Add("@p_Notes", obj.Notes, DbType.String, size: 2000);
                    para.Add("@p_Product_Manager", obj.ProductManager, DbType.String, size: 8);
                    para.Add("@p_RSG_UID", obj.RSGUID, DbType.String, size: 500);
                    para.Add("@p_Active", obj.Active, DbType.Boolean);
                    para.Add("@p_Created_By", obj.CreatedBy, DbType.String, size: 8);
                    para.Add("@p_Created_On", obj.CreatedOn, DbType.DateTime);
                    para.Add("@p_Updated_By", obj.UpdatedBy, DbType.String, size: 8);
                    para.Add("@p_Last_Updated", obj.LastUpdated, DbType.DateTime);
                    para.Add("@p_Id", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);

                    conn.Execute(procName, para, commandType: CommandType.StoredProcedure);

                    if (obj.Id == 0)
                    {
                        obj.Id = para.Get<int>("@p_Id");
                    }

                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return retVal;
            
        }
        private IVehicle HydrateVehicleFromProgramme(Programme programme, int? vehicleIndex)
        {
            if (programme == null)
                return new EmptyVehicle();

            return new Vehicle()
            {
                Make = programme.VehicleMake,
                Code = programme.VehicleName,
                ProgrammeId = programme.Id,
                ModelYear = programme.ModelYear,
                Gateway = vehicleIndex.GetValueOrDefault() == 0 ? programme.Gateway : string.Empty,
                Description = string.Format("{0} - {1}", programme.VehicleName, programme.VehicleAKA),
                Programmes = new List<Programme>() { programme }
            };
        }
 private IVehicle HydrateVehicleFromProgramme(Programme programme)
 {
     return HydrateVehicleFromProgramme(programme, null);
 }
 private string Emailtext(IEnumerable<string> replacements, int iStudentId, MarksCalculator mcalc, out DataRow row)
 {
     var emailtext = txtEmailBody.Text;
     row = _config.GetStudentRow(iStudentId);
     foreach (var item in replacements)
     {
         var repvalue = "";
         switch (item)
         {
             case "MarkReport":
                 repvalue = _config.GetStudentReport(iStudentId, chkSendModerationNotice.Checked);
                 break;
             case "FinalMark":
                 repvalue = mcalc.GetFinalMark(row["SUB_NumericUserId"].ToString(), _config).ToString();
                 break;
             case "AllMarks":
             {
                 var p = new Programme(row["SUB_NumericUserId"].ToString());
                 repvalue = p.ShortMarksReport();
             }
                 break;
             default:
                 try
                 {
                     repvalue = row[item].ToString();
                 }
                 catch (Exception ex)
                 {
                 }
                 break;
         }
         emailtext = emailtext.Replace("{" + item + "}", repvalue);
     }
     return emailtext;
 }
 public async Task<IEnumerable<MarketGroup>> ListAvailableMarketGroups(VehicleFilter filter, Programme forProgramme)
 {
     var marketGroups = Enumerable.Empty<MarketGroup>();
     if (filter.DocumentId.HasValue) {
         marketGroups =  await Task.FromResult(_marketGroupDataStore
                            .MarketGroupGetMany(forProgramme.Id, filter.DocumentId.Value, true));
     } else {
         marketGroups = await Task.FromResult(_marketGroupDataStore
                            .MarketGroupGetMany(true));
     }
     return marketGroups;
 }
        public void DocGetConfiguration(OXODoc currentDoc)
        {
            Programme retVal = new Programme();
            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@p_doc_id", currentDoc.Id, dbType: DbType.Int32);
                    using (var multi = conn.QueryMultiple("dbo.OXO_Doc_GetConfiguration", para, commandType: CommandType.StoredProcedure))
                    {
                        currentDoc.AllBodies = multi.Read<ModelBody>().ToList();
                        currentDoc.AllEngines = multi.Read<ModelEngine>().ToList();
                        currentDoc.AllTransmissions = multi.Read<ModelTransmission>().ToList();
                        currentDoc.AllTrims = multi.Read<ModelTrim>().ToList();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

     
        }