Ejemplo n.º 1
0
 public static void editDonor(Request d)
 {
     using (BTProjectEntities db = new BTProjectEntities())
     {
         //can change donor email
         List <request_tbl> reqs = db.request_tbl.Where(r => r.donorEmail == d.donorEmail).ToList();
         //reqs.ForEach( req => req.donorEmail = d.donorEmail);
         reqs.ForEach(req =>
         {
             req.password        = d.password;
             req.donorName       = d.donorName;
             db.Entry(req).State = System.Data.Entity.EntityState.Modified;
         });
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        public static void deleteMatch(Matching m, string donorEmail)
        {
            //db.Matching_tbl.Remove(Matching.DTOToc(m));
            //this is becuse we nee dto mark the object in the context as deleted
            // ef will afterwards compare the context and find the changes and update as we have marked
            //we only need to use this way if we generate the object on our own
            //otherwise we can simply use remove() if retrieved from dbcontext
            using (BTProjectEntities db = new BTProjectEntities())
            {
                bool oldValidateOnSaveEnabled = db.Configuration.ValidateOnSaveEnabled;

                try
                {
                    db.Configuration.ValidateOnSaveEnabled = false;

                    db.Entry(Matching.DTOToc(m)).State = EntityState.Deleted;
                    //db.Matching_tbl.Attach(Matching.DTOToc(m));

                    db.SaveChanges();
                }
                finally
                {
                    db.Configuration.ValidateOnSaveEnabled = oldValidateOnSaveEnabled;
                }
            }
            using (BTProjectEntities db = new BTProjectEntities())
            {
                //send emails to learner and donor
                List <Learner> l       = Learner.cToDTO(db.learners_tbl.ToList());
                Learner        learner = l.FirstOrDefault(le => le.learnerId == m.learnerId);


                Email e = new Email();
                //email donor
                e.sendEmailViaWebApi("", donorEmail, "ביטול השתתפות לומד בתוכנית לימוד", "C:\\Users\tzipp\\BTProject\\cheshvanProject\\BLL\\BLL\\cancelMatching.rtf", "", "", " הלומד" + learner.learnerName + "מזהה תוכנית הלימוד " + " " + m.reqId);

                //emailLearner

                e.sendEmailViaWebApi("", learner.learnerEmail, "ביטול השתתפות בתוכנית לימוד", "C:\\Users\tzipp\\BTProject\\cheshvanProject\\BLL\\BLL\\CancelMatchingLearner.rtf", "", "", "מזהה תוכנית הלימוד" + m.reqId + " מייל היזם:" + donorEmail);
            }
            //db.Entry(Matching.DTOToc(m)).State = EntityState.Deleted;
            //db.SaveChanges();
        }
Ejemplo n.º 3
0
        //-----------Edit----------------------------
        public static void editLearner(Learner l)
        {
            using (BTProjectEntities db = new BTProjectEntities())
            {
                if (l.password != null && l.endDate > DateTime.Today)
                {
                    List <learners_tbl> learners = db.learners_tbl.Where(r => r.learnerId == l.learnerId).ToList();
                    learners.ForEach(le =>
                    {
                        le.password    = l.password;
                        le.learnerName = l.learnerName;

                        le.occuptionId     = l.occuptionId;
                        le.startDate       = l.startDate;
                        le.endDate         = l.endDate;
                        le.gender          = l.gender;
                        db.Entry(le).State = System.Data.Entity.EntityState.Modified;
                    });

                    db.SaveChanges();
                }
            }
        }