Example #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);
 }
Example #2
0
 public static ProfessionalDTO SelectProfessionalByUserID(int id)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var professional = db.Professionals.FirstOrDefault(p => p.userID == id);
         if (professional == null)
         {
             return(null);
         }
         return(Converters.ProfessionalC.ToProfessionalDto(professional));
     }
 }
Example #3
0
 public static UserDto Login(string username, string password)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var user = db.Users.FirstOrDefault(p => p.UserName == username && p.Password == password);
         if (user == null)
         {
             return(null);
         }
         return(UserC.ToUserDto(user));
     }
 }
Example #4
0
        public static List <ProfessionalDTO> SelectProffesionals()
        {
            List <ProfessionalDTO> ProffesionalsList = new List <ProfessionalDTO>();

            using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
            {
                var proffesionals = db.Professionals.OrderBy(p => p.ProfessionKind).ToList();
                foreach (var proffesional in proffesionals)
                {
                    ProffesionalsList.Add(ProfessionalC.ToProfessionalDto(proffesional));
                }
            }
            return(ProffesionalsList);
        }
Example #5
0
        public static UserDto IsLoggedIn(string token)
        {
            int idUser = TokenLogic.DecodeToken(token);

            using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
            {
                var user = db.Users.FirstOrDefault(u => u.Id == idUser);
                if (user == null)
                {
                    return(null);
                }
                return(UserC.ToUserDto(user));
            }
        }
        public static List <KinderGardenDto> SelectKinderGardens()
        {
            List <KinderGardenDto> listKinderGardens = new List <KinderGardenDto>();

            using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
            {
                var kinderGardens = db.KinderGardens.ToList();
                foreach (var kinderGarden in kinderGardens)
                {
                    listKinderGardens.Add(KinderGardenC.ToKinderGardenDto(kinderGarden));
                }
            }
            return(listKinderGardens);
        }
Example #7
0
 public static void EditProffesional(int id, DTO.ProfessionalDTO professional)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var editProffesional = db.Professionals.FirstOrDefault(p => p.Id == id);
         if (editProffesional != null)
         {
             editProffesional.Name        = professional.Name;
             editProffesional.NumHourWork = professional.NumHourWork;
             editProffesional.Sunday      = professional.Sunday;
             editProffesional.Monday      = professional.Monday;
             editProffesional.Thuesday    = professional.Thuesday;
             editProffesional.Wednesday   = professional.Wednesday;
             editProffesional.Tursday     = professional.Tursday;
         }
         db.SaveChanges();
     }
 }
        public static List <KinderGardenDto> SelectWorkersKinderGardens(int profossionalId)//בוחרת גנים שהעובדת עובדת בהם
        {
            List <KinderGardenDto> listKinderGardens = new List <KinderGardenDto>();
            List <int>             kndId             = new List <int>();

            using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
            {
                var calendersKinderGarden = db.Calanders.Where(c => c.ProfessionalId == profossionalId && c.DateStart != null && c.DateStart.Value.Year == year).ToList();

                foreach (var calenderkndg in calendersKinderGarden)
                {
                    if (kndId.Contains(calenderkndg.KinderGardenId.Value) == false)
                    {
                        kndId.Add(calenderkndg.KinderGardenId.Value);
                    }
                }
                foreach (var kndid in kndId)
                {
                    listKinderGardens.Add(KinderGardenC.ToKinderGardenDto(db.KinderGardens.First(knd => knd.Id == kndid)));
                }
            }
            return(listKinderGardens);
        }
Example #9
0
 public static void DeleteProffesional(int id)
 {
     try
     {
         using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
         {
             var proffesional = db.Professionals.FirstOrDefault(p => p.Id == id);
             if (proffesional != null)
             {
                 db.Professionals.Remove(proffesional);
             }
             var userProffesional = db.Users.FirstOrDefault(uP => uP.Password == proffesional.Id.ToString());
             if (userProffesional != null)
             {
                 db.Users.Remove(userProffesional);
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }