Esempio n. 1
0
 public static void InsertProffesional(DTO.ProffessionalPost proffessional)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         db.Users.Add
         (
             new DAL.User()
         {
             KindUser  = 2,
             FirstName = proffessional.Name,
             UserName  = "******",
             Password  = proffessional.Id.ToString(),
             Email     = proffessional.ProffesionalEmail,
             LastName  = ""
         }
         );
         db.SaveChanges();
         ProfessionalDTO professionalDto = new ProfessionalDTO()
         {
             Monday         = proffessional.Monday,
             Name           = proffessional.Name,
             NumHourWork    = proffessional.NumHourWork,
             ProfessionKind = proffessional.ProfessionKind,
             Sunday         = proffessional.Sunday,
             Thuesday       = proffessional.Thuesday,
             Tursday        = proffessional.Tursday,
             Wednesday      = proffessional.Wednesday,
             UserID         = db.Users.FirstOrDefault(u => u.Password == proffessional.Id.ToString()).Id
         };
         db.Professionals.Add(ProfessionalC.ToProfessional(professionalDto));
         //send Email Please
         db.SaveChanges();
     }
     PublicLogic.SendEmail("TLT2", proffessional.Id.ToString(), proffessional.ProffesionalEmail);
 }
Esempio n. 2
0
 public static void InsertChild(DTO.ChildPost child, string kGardenName)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         int  kGardenID = db.KinderGardens.First(kg => kg.Name == kGardenName).Id;
         User user      = new User()
         {
             LastName  = child.LastName,
             FirstName = child.ParentName,
             KindUser  = 3,
             UserName  = "******" + "3",
             Email     = child.ParentEmail,
             Password  = child.Tz,
         };
         db.Users.Add(user);
         db.SaveChanges();
         ChildDto childDto = new ChildDto()
         {
             FirstName       = child.FirstName,
             LastName        = child.LastName,
             BornDate        = child.BornDate,
             NumHoursConfirm = child.NumHoursConfirm,
             Tz       = child.Tz,
             ParentID = db.Users.First(u => u.Password == child.Tz).Id
         };
         db.Children.Add(ChildC.ToChildDAL(childDto));
         db.ChildKinderGardens.Add(new ChildKinderGarden()
         {
             ChildID       = child.Id,
             KindrGardenID = kGardenID,
             BeginYear     = PublicLogic.CalcBeaginYear(),
             EndYear       = PublicLogic.CalcEndYear(),
         });
         db.SaveChanges();
         PublicLogic.SendEmail("TLT3", child.Tz, child.ParentEmail);
     }
 }