public static void Add(CreditAddLog creditAddLog)
 {
     using (UpsilabEntities context = new UpsilabEntities())
     {
         context.CreditAddLog.AddObject(creditAddLog);
         context.SaveChanges();
     }
 }
        public ActionResult AddCredit()
        {
            var idFirmParent = Request.Params["idFirmParent"];
            var creditAAjouter = Request.Params["creditAAjouter"];
            var motifCredit = Request.Params["motifCredit"];

            if (idFirmParent != null && creditAAjouter != null && motifCredit != null)
            {
                Guid gIdFirmParent;
                int newCreditCount = 0;

                Guid.TryParse(idFirmParent, out gIdFirmParent);
                Int32.TryParse(creditAAjouter, out newCreditCount);

                FirmInstitution f = FirmInstitutionBL.GetFirmInstitutionByIdFirmInstitution(gIdFirmParent);
                
                if (f != null)
                {
                    var currentCredit = f.CreditCount + newCreditCount;
                    FirmInstitutionBL.UpdateFirmInstitution(f.idFirmInstitution, "FirmInstitution.CreditCount", currentCredit.ToString());
                }

                // ajout historique
                CreditAddLog newLog = new CreditAddLog(){
                    Id = GuidHelper.GenerateGuid(),
                    IdFirmInstitutionParent = gIdFirmParent,
                    CreditCount = newCreditCount,
                    CreditMotif = motifCredit,
                    DateCreated = DateTime.Now
                };

                CreditAddLogBL.Add(newLog);
            }

            return RedirectToAction("Index");
        }