public void BuildObjects(Sanction sanction)
 {
     sanction.Terminal = new TerminalCrud().Retrieve <Terminal>(sanction.Terminal);
     sanction.Route    = new RouteCrud().Retrieve <Route>(sanction.Route);
     sanction.Type     = CrudFactory.RetrieveSanctionTypeById <SanctionType>(sanction.Type);
     sanction.Company  = new CompanyCrud().Retrieve <Company>(sanction.Company);
 }
        public BaseEntity BuildObject(Dictionary <string, object> row)
        {
            var Company = new Company
            {
                IdCompany = GetIntValue(row, IDCOMPANY)
            };

            var Route = new Route
            {
                IdRoute = GetIntValue(row, IDROUTE)
            };

            var Terminal = new Terminal
            {
                IdTerminal = GetIntValue(row, IDTERMINAL)
            };

            var SanctionType = new SanctionType
            {
                IdType = GetIntValue(row, IDSANCTIONTYPE)
            };

            var Sanction = new Sanction
            {
                IdSanction  = GetIntValue(row, IDSANCTION),
                Date        = GetStringValue(row, DATE),
                Description = GetStringValue(row, DESCRIPTION),
                Company     = Company,
                Route       = Route,
                Terminal    = Terminal,
                Type        = SanctionType
            };

            return(Sanction);
        }
Exemplo n.º 3
0
 private void btndelete_Click(object sender, EventArgs e)
 {
     try
     {
         using (Sanction sanction = new Sanction())
         {
             sanction.ID = Convert.ToInt32(idvisiable.Text);
             if (sanction.Delete_Sanction(sanction))
             {
                 MessageBox.Show("لقد تم الغاء الموظفين", "معلومات", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 using (Context ctx = new Context())
                 {
                     datagrid.DataSource = ctx.Sentions;
                 }
                 Fix();
             }
             else
             {
                 MessageBox.Show("لم يتم الغاء الموظفين", "خطاء", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "خطاء", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 4
0
        static SanctionData()
        {
            Sanctions = new List <Sanction>();

            string          myConnectionString = "Server=192.168.111.113;Port=3306;User Id=savahha;Password=1111;Database=rentandsale;OldGuids=True;Connection Timeout=200";
            MySqlConnection connection         = new MySqlConnection(myConnectionString);

            connection.Open();
            MySqlCommand    newCommand      = new MySqlCommand("SELECT * FROM sanctions", connection);
            MySqlDataReader mySqlDataReader = newCommand.ExecuteReader();

            if (mySqlDataReader.HasRows)
            {
                while (mySqlDataReader.Read())
                {
                    object _sanctionID = mySqlDataReader.GetValue(0);
                    object _name       = mySqlDataReader.GetValue(1);
                    object _cost       = mySqlDataReader.GetValue(2);

                    var sanction = new Sanction {
                        ID_Sanction = Int32.Parse(_sanctionID.ToString()), Name = _name.ToString(), Cost = Int32.Parse(_cost.ToString())
                    };
                    Sanctions.Add(sanction);
                }
            }
            connection.Close();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Constructeur d'un objet représentant une tricherie
 /// </summary>
 /// <param name="idChallenge">Identifiant du <see cref="Challenge"/> concerné par la tricherie</param>
 /// <param name="idUser">Identifiant du <see cref="User"/> ayant triché</param>
 /// <param name="idSessionChallenge">Identifiant du <see cref="SessionChallenge"/> pendant lequel le challenger a triché</param>
 /// <param name="cheatDescription">Description de la triche effectuée</param>
 /// <param name="sanctionApplied">Sanction appliquée suite à la tricherie</param>
 public Cheat(int idChallenge, int idUser, int idSessionChallenge, int cheatDescription, Sanction sanctionApplied)
 {
     this.idChallenge        = idChallenge;
     this.idUser             = idUser;
     this.idSessionChallenge = idSessionChallenge;
     this.cheatDescription   = cheatDescription;
     this.sanctionApplied    = sanctionApplied;
 }
 public void Update(Sanction sanction)
 {
     using (var context = new EduhubContext(_connectionString))
     {
         var sanctionDto = context.Sanctions.FirstOrDefault(s => s.Id == sanction.Id);
         sanctionDto.ParseFromSanction(sanction);
         context.SaveChanges();
     }
 }
        public Sanction RetrieveById(Sanction sanction)
        {
            Sanction NewSanction = CrudFactory.Retrieve <Sanction>(sanction);

            ValidateObject(NewSanction);
            BuildObjects(NewSanction);

            return(NewSanction);
        }
 public void Add(Sanction sanction)
 {
     if (sanction == null)
     {
         throw new ArgumentNullException();
     }
     sanction.Id = IntIterator.GetNextId();
     _listOfSanctions.Add(sanction);
 }
 public static void ParseFromSanction(this SanctionDto result, Sanction sourse)
 {
     result.BrokenRule     = sourse.BrokenRule;
     result.UserId         = sourse.UserId;
     result.ModeratorId    = sourse.ModeratorId;
     result.IsTemporary    = sourse.IsTemporary;
     result.ExpirationDate = sourse.ExpirationDate;
     result.Type           = sourse.Type;
     result.IsActive       = sourse.IsActive;
 }
 public void Add(Sanction sanction)
 {
     using (var context = new EduhubContext(_connectionString))
     {
         var sanctionDto = new SanctionDto();
         sanctionDto.ParseFromSanction(sanction);
         context.Sanctions.Add(sanctionDto);
         context.SaveChanges();
         sanction.Id = sanctionDto.Id;
     }
 }
        public void Update(Sanction sanction)
        {
            if (sanction == null)
            {
                throw new ArgumentNullException();
            }
            var currentSanction = _listOfSanctions.Find(current => current.Id == sanction.Id) ??
                                  throw new SanctionNotFoundException(sanction.Id);

            currentSanction = sanction;
        }
 public void Update(Sanction sanction)
 {
     try
     {
         ValidateFields(sanction);
         CrudFactory.Update(sanction);
     }
     catch (Exception bex)
     {
         ExceptionManager.GetInstance().Process(bex);
     }
 }
 public void ValidateObject(Sanction sanction)
 {
     try
     {
         if (sanction == null)
         {
             throw new BusinessException(5);
         }
     }
     catch (Exception bex)
     {
         ExceptionManager.GetInstance().Process(bex);
     }
 }
        public IHttpActionResult Delete(Sanction sanction)
        {
            try
            {
                var Mngr = new SanctionManager();
                Mngr.Delete(sanction);

                ApiResp = new ApiResponse
                {
                    Message = "Sanción eliminada exitosamente"
                };

                return(Ok(ApiResp));
            }
            catch (BusinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Sanction sanction = new Sanction();
         sanction.SanctionName         = txtname.Text;
         sanction.Sanction_Description = txtdecription.Text;
         if (sanction.Add_Sanction(sanction))
         {
             MessageBox.Show("لقد تم اضافة الجزاء", "معلومات", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("لم يتم اضافة الجزاء", "خطاء", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 16
0
        public int AddSanction(string brokenRule, int userId, int moderatorId, SanctionType type)
        {
            Ensure.String.IsNotNullOrWhiteSpace(brokenRule);
            Ensure.Any.IsNotNull(type);
            Ensure.Any.IsNotNull(_userRepository.GetUserById(userId), nameof(AddSanction),
                                 opt => opt.WithException(new UserNotFoundException(userId)));
            Ensure.Bool.IsTrue(_userRepository.GetUserById(moderatorId).Type.Equals(UserType.Moderator) ||
                               _userRepository.GetUserById(moderatorId).Type.Equals(UserType.Admin),
                               nameof(AddSanction),
                               opt => opt.WithException(new NotEnoughPermissionsException(moderatorId)));

            var suspectedUser = _userRepository.GetUserById(userId);
            var sanction      = new Sanction(brokenRule, userId, moderatorId, type);

            _sanctionRepository.Add(sanction);

            _publisher.PublishEvent(new SanctionsAppliedEvent(brokenRule, type, suspectedUser.UserProfile.Name,
                                                              userId));

            return(sanction.Id);
        }
Exemplo n.º 17
0
 private void btnedit_Click(object sender, EventArgs e)
 {
     try
     {
         using (Sanction sanction = new Sanction())
         {
             sanction.ID                   = int.Parse(IDvisiable.Text);
             sanction.SanctionName         = txtname.Text;
             sanction.Sanction_Description = txtdecription.Text;
             if (sanction.Edit_Sanction(sanction))
             {
                 MessageBox.Show("لقد تم تعديل الجزاء", "معلومات", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("يوجد خطاء  ما", "خطاء", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "خطاء", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 18
0
        public JsonResult update(PersonModel PPP)
        {
            Partie ppp = db.Partie.First(t => t.Id == PPP.Id);

            ppp.Nom           = PPP.Nom;
            ppp.Prenom        = PPP.Prenom;
            ppp.DateNaissance = (DateTime)Convert.ToDateTime(PPP.DateNaissance);


            ppp.LieuNaissance = PPP.LieuNaissance;

            ppp.GenreId = PPP.GenreId;

            ppp.Cin = PPP.Cin;

            ppp.NationaliteId = (int)Convert.ToInt64(PPP.NationaliteId);

            ppp.Adresse = PPP.Adresse;

            ppp.VilleId  = (int)Convert.ToInt64(PPP.VilleId);
            ppp.MetierId = PPP.MetierId;
            db.SaveChanges();
            Obtention pp = db.Obtention.First(u => u.PartieId == PPP.Id);

            pp.SpecialiteId = PPP.SpecialiteId;
            pp.CategorieId  = PPP.CategorieId;
            pp.Annee        = (DateTime)Convert.ToDateTime(PPP.Annee);
            db.SaveChanges();
            CoordonneesProfessionnelles p = db.CoordonneesProfessionnelles.First(c => c.PartieId == PPP.Id);

            p.BarreauId          = (int)Convert.ToInt64(PPP.BarreauId);
            p.ReferenceNational  = PPP.ReferenceNat;
            p.OrganeId           = (int)Convert.ToInt64(PPP.OrganId);
            p.SituationPId       = (int)Convert.ToInt64(PPP.SituationPId);
            p.AnneeDA            = (DateTime)Convert.ToDateTime(PPP.AnneeDA);
            p.AnneeAY            = (DateTime)Convert.ToDateTime(PPP.AnneeAY);
            p.CourCassationId    = (int)Convert.ToInt64(PPP.CourCassationId);
            p.AnneeACC           = (DateTime)Convert.ToDateTime(PPP.AnneeACC);
            p.StatutAHId         = (int)Convert.ToInt64(PPP.StatutAHId);
            p.AnneeSt            = (DateTime)Convert.ToDateTime(PPP.AnneeSt);
            p.AnneeRSt           = (DateTime)Convert.ToDateTime(PPP.AnneeRSt);
            p.StatutCapitaineId  = (int)Convert.ToInt64(PPP.StatutCapitaineId);
            p.AnneeCapitaine     = (DateTime)Convert.ToDateTime(PPP.AnneeCapitaine);
            p.AnneeFinSt         = (DateTime)Convert.ToDateTime(PPP.AnneeFinSt);
            p.AvocatAssistantId  = (int)Convert.ToInt64(PPP.AvocatAssistantId);
            p.AvocatParId        = (int)Convert.ToInt64(PPP.AvocatParId);
            p.AvocatCohId        = (int)Convert.ToInt64(PPP.AvocatCohId);
            p.AssuranceId        = (int)Convert.ToInt64(PPP.AssuranceId);
            p.NomAvocatAss       = (int)Convert.ToInt64(PPP.NomAvocatAss);
            p.NomAvocatPar       = (int)Convert.ToInt64(PPP.NomAvocatPar);
            p.NomAvocatCoh       = (int)Convert.ToInt64(PPP.NomAvocatCoh);
            p.NomAvocatAssurance = (int)Convert.ToInt64(PPP.NomAvocatAssurance);
            p.NomSociete         = PPP.NomSociete;
            db.SaveChanges();
            Stage pppp = db.Stage.First(s => s.PartieId == PPP.Id);

            pppp.AnneeDebut     = (DateTime)Convert.ToDateTime(PPP.AnneeDebut);
            pppp.AnneeArret     = (DateTime)Convert.ToDateTime(PPP.AnneeArret);
            pppp.AnneeReprendre = (DateTime)Convert.ToDateTime(PPP.AnneeReprendre);
            pppp.AnneFin        = (DateTime)Convert.ToDateTime(PPP.AnneeFin);
            pppp.AnneeSupp      = (DateTime)Convert.ToDateTime(PPP.AnneeSupp);
            pppp.AvocatStageId  = (int)Convert.ToInt64(PPP.AvocatStage);
            db.SaveChanges();
            AvocatMembre ppppp = db.AvocatMembre.First(a => a.PartieId == PPP.Id);

            ppppp.NominationId = (int)Convert.ToInt64(PPP.NominationId);
            ppppp.AnneeMembre  = (DateTime)Convert.ToDateTime(PPP.AnneeMembre);
            db.SaveChanges();

            Audience ppppppp = db.Audience.First(au => au.PartieId == PPP.Id);

            ppppppp.AnneeAudience = (DateTime)Convert.ToDateTime(PPP.AnneeAudience);
            ppppppp.DecisionId    = (int)Convert.ToInt64(PPP.DecisionId);
            db.SaveChanges();
            Jugement pppppppp = db.Jugement.First(j => j.PartieId == PPP.Id);

            pppppppp.Jugementt    = PPP.Jugement;
            pppppppp.DateJugement = (DateTime)Convert.ToDateTime(PPP.DateJugement);
            db.SaveChanges();
            Sanction ppppppppp = db.Sanction.First(sa => sa.PartieId == PPP.Id);

            ppppppppp.SanctionId   = (int)Convert.ToInt64(PPP.SanctionId);
            ppppppppp.DateSanction = (DateTime)Convert.ToDateTime(PPP.DateSanction);



            db.SaveChanges();
            PoursuiteJuridique pppppp = db.PoursuiteJuridique.First(P => P.PartieId == PPP.Id);

            pppppp.NumeroPole    = (int)Convert.ToInt64(PPP.NumeroPole);
            pppppp.JuridictionId = (int)Convert.ToInt64(PPP.JuridictionId);
            pppppp.NumeroDossier = (int)Convert.ToInt64(PPP.NumeroDossier);
            pppppp.Accusation    = PPP.Accusation;
            pppppp.ChaitreSuivi  = PPP.ChapitreSuivi;
            db.SaveChanges();

            return(Json("succes"));
        }
Exemplo n.º 19
0
        public JsonResult AddP(PersonModel PP)
        {
            Partie p = new Partie();

            p.Nom           = PP.Nom;
            p.Prenom        = PP.Prenom;
            p.DateNaissance = (DateTime)Convert.ToDateTime(PP.DateNaissance);
            p.LieuNaissance = PP.LieuNaissance;
            p.GenreId       = PP.GenreId;
            p.Cin           = PP.Cin;
            p.NationaliteId = (int)Convert.ToInt64(PP.NationaliteId);
            p.Adresse       = PP.Adresse;
            p.VilleId       = (int)Convert.ToInt64(PP.VilleId);
            p.MetierId      = (int)Convert.ToInt64(PP.MetierId);

            db.Partie.Add(p);
            db.SaveChanges();
            long      latest = p.Id;
            Obtention pp     = new Obtention();

            pp.PartieId     = latest;
            pp.CategorieId  = PP.CategorieId;
            pp.SpecialiteId = PP.SpecialiteId;
            pp.Annee        = (DateTime)Convert.ToDateTime(PP.Annee);
            db.Obtention.Add(pp);
            db.SaveChanges();
            CoordonneesProfessionnelles ppp = new CoordonneesProfessionnelles();

            ppp.PartieId           = latest;
            ppp.BarreauId          = (int)Convert.ToInt64(PP.BarreauId);
            ppp.ReferenceNational  = PP.ReferenceNat;
            ppp.OrganeId           = (int)Convert.ToInt64(PP.OrganId);
            ppp.SituationPId       = (int)Convert.ToInt64(PP.SituationPId);
            ppp.AnneeDA            = (DateTime)Convert.ToDateTime(PP.AnneeDA);
            ppp.AnneeAY            = (DateTime)Convert.ToDateTime(PP.AnneeAY);
            ppp.CourCassationId    = (int)Convert.ToInt64(PP.CourCassationId);
            ppp.AnneeACC           = (DateTime)Convert.ToDateTime(PP.AnneeACC);
            ppp.StatutAHId         = (int)Convert.ToInt64(PP.StatutAHId);
            ppp.AnneeSt            = (DateTime)Convert.ToDateTime(PP.AnneeSt);
            ppp.AnneeRSt           = (DateTime)Convert.ToDateTime(PP.AnneeRSt);
            ppp.StatutCapitaineId  = (int)Convert.ToInt64(PP.StatutCapitaineId);
            ppp.AnneeCapitaine     = (DateTime)Convert.ToDateTime(PP.AnneeCapitaine);
            ppp.AnneeFinSt         = (DateTime)Convert.ToDateTime(PP.AnneeFinSt);
            ppp.AvocatAssistantId  = (int)Convert.ToInt64(PP.AvocatAssistantId);
            ppp.AvocatParId        = (int)Convert.ToInt64(PP.AvocatParId);
            ppp.AvocatCohId        = (int)Convert.ToInt64(PP.AvocatCohId);
            ppp.AssuranceId        = (int)Convert.ToInt64(PP.AssuranceId);
            ppp.NomSociete         = PP.NomSociete;
            ppp.NomAvocatAss       = PP.NomAvocatAss;
            ppp.NomAvocatPar       = PP.NomAvocatPar;
            ppp.NomAvocatCoh       = PP.NomAvocatCoh;
            ppp.NomAvocatAssurance = PP.NomAvocatAssurance;
            db.CoordonneesProfessionnelles.Add(ppp);
            db.SaveChanges();
            Stage pppp = new Stage();

            pppp.PartieId       = latest;
            pppp.AnneeDebut     = (DateTime)Convert.ToDateTime(PP.AnneeDebut);
            pppp.AnneeArret     = (DateTime)Convert.ToDateTime(PP.AnneeArret);
            pppp.AnneeReprendre = (DateTime)Convert.ToDateTime(PP.AnneeReprendre);
            pppp.AnneFin        = (DateTime)Convert.ToDateTime(PP.AnneeFin);
            pppp.AnneeSupp      = (DateTime)Convert.ToDateTime(PP.AnneeSupp);
            pppp.AvocatStageId  = (int)Convert.ToInt64(PP.AvocatStage);
            db.Stage.Add(pppp);
            db.SaveChanges();

            AvocatMembre ppppppppp = new AvocatMembre();

            ppppppppp.PartieId     = latest;
            ppppppppp.NominationId = (int)Convert.ToInt64(PP.NominationId);
            ppppppppp.AnneeMembre  = (DateTime)Convert.ToDateTime(PP.AnneeMembre);
            db.AvocatMembre.Add(ppppppppp);
            db.SaveChanges();
            Audience pppppp = new Audience();

            pppppp.PartieId      = latest;
            pppppp.AnneeAudience = (DateTime)Convert.ToDateTime(PP.AnneeAudience);
            pppppp.DecisionId    = (int)Convert.ToInt64(PP.DecisionId);
            db.Audience.Add(pppppp);
            db.SaveChanges();
            Jugement ppppppp = new Jugement();

            ppppppp.PartieId     = latest;
            ppppppp.Jugementt    = PP.Jugement;
            ppppppp.DateJugement = (DateTime)Convert.ToDateTime(PP.DateJugement);
            db.Jugement.Add(ppppppp);
            db.SaveChanges();
            Sanction pppppppp = new Sanction();

            pppppppp.PartieId     = latest;
            pppppppp.SanctionId   = (int)Convert.ToInt64(PP.SanctionId);
            pppppppp.DateSanction = (DateTime)Convert.ToDateTime(PP.DateSanction);
            db.Sanction.Add(pppppppp);
            db.SaveChanges();
            PoursuiteJuridique ppppp = new PoursuiteJuridique();

            ppppp.PartieId      = latest;
            ppppp.NumeroPole    = PP.NumeroPole;
            ppppp.JuridictionId = (int)Convert.ToInt64(PP.JuridictionId);
            ppppp.NumeroDossier = PP.NumeroDossier;
            ppppp.Accusation    = PP.Accusation;
            ppppp.ChaitreSuivi  = PP.ChapitreSuivi;

            db.PoursuiteJuridique.Add(ppppp);
            db.SaveChanges();



            return(Json("succes"));
        }
 public void Delete(Sanction sanction)
 {
     CrudFactory.Delete(sanction);
 }