Beispiel #1
0
        //הוספת כלבים למשתמש
        public void AddDogsForUser(UserDetailsView userDetails)
        {
            try
            {
                Entities context = new Entities();

                for (int i = 0; i < userDetails.UserarrayDogs.Count; i++)
                {
                    AddOneDogForUser(userDetails.UserarrayDogs[i]);
                    //UserDogs userDogs  = new UserDogs();
                    //userDogs.DogBirthDate = userDetails.UserarrayDogs[i].DogBirthDate;
                    //userDogs.DogComments = userDetails.UserarrayDogs[i].DogComments;
                    //userDogs.DogDig  = userDetails.UserarrayDogs[i].DogDig;
                    //userDogs.DogFriendlyWith = userDetails.UserarrayDogs[i].DogFriendlyWith;
                    //userDogs.DogGender = userDetails.UserarrayDogs[i].DogGender;
                    //userDogs.DogImage = userDetails.UserarrayDogs[i].DogImage;
                    //userDogs.DogJump = userDetails.UserarrayDogs[i].DogJump;
                    //userDogs.DogName = userDetails.UserarrayDogs[i].DogName;
                    //userDogs.DogNeuter = userDetails.UserarrayDogs[i].DogNeuter;
                    //userDogs.DogRabiesVaccine = userDetails.UserarrayDogs[i].DogRabiesVaccine;
                    //userDogs.DogShvav = userDetails.UserarrayDogs[i].DogShvav;
                    //userDogs.DogStatus = 21;
                    //userDogs.DogType = userDetails.UserarrayDogs[i].DogType;
                    //userDogs.DogUserID = userDetails.UserID;
                    //context.UserDogs.Add(userDogs);
                    //context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        //שליפת משתמש
        public UserDetailsView GetUser(int userid)
        {
            try
            {
                UserDetailsView userDetails = null;

                Entities context = new Entities();


                var User = context.UsersTbl
                           .Where(user => user.UserID == userid && user.UserStatusCode != 22).FirstOrDefault();


                if (User != null)
                {
                    userDetails = new UserDetailsView();
                    userDetails.Acceptmessages     = User.Acceptmessages;
                    userDetails.DaysSumForDiscount = User.DaysSumForDiscount;
                    userDetails.UserFirstName      = User.UserFirstName;
                    userDetails.UserLastName       = User.UserLastName;
                    userDetails.UserEmail          = User.UserEmail;
                    userDetails.UserID             = User.UserID;
                    userDetails.UserPhone2         = User.UserPhone2;
                    userDetails.UserPhone1         = User.UserPhone1;
                    userDetails.UserComments       = User.UserComments;
                    userDetails.UserCity           = User.UserCity;
                    userDetails.UserAddress        = User.UserAddress;
                    var dogs = context.UserDogs
                               .Where(userDog => userDog.DogUserID == User.UserID).Count();
                    userDetails.DogsNumber = dogs;

                    var reservations = context.OrdersTbl
                                       .Where(userres => userres.OrderUserId == User.UserID).Count();
                    userDetails.ReservationsNumber = context.OrdersTbl.Count();
                    userDetails.UserName           = User.UserName;
                    userDetails.UserStatusCode     = User.UserStatusCode;
                    var vet = context.veterinarTbl
                              .Where(v => v.VeterinarId == User.UserVeterinarId).FirstOrDefault();
                    userDetails.UserVeterinarId  = User.UserVeterinarId;
                    userDetails.VeterinarAddress = vet.VeterinarAddress;
                    userDetails.VeterinarCity    = vet.VeterinarCity;
                    userDetails.VeterinarEmail   = vet.VeterinarEmail;
                    userDetails.VeterinarName    = vet.VeterinarName;
                    userDetails.VeterinarPhone1  = vet.VeterinarPhone1;

                    //  GetUserDogs(userDetails); //שליפת כלבים למשתמש
                    //   OrderService orderService = new OrderService();
                    //    orderService.GetUserOrders(userDetails);//שליפת הזמנות למשתמש
                    //  HttpContext.Current.Session["userDetails"] = userDetails;
                }
                return(userDetails);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public List <DogDetailsView> GetUserDogs(int userid)

        {
            try
            {
                UserDetailsView userDetailsView = new UserDetailsView(userid);
                GetUserDogs(userDetailsView);

                return(userDetailsView.UserarrayDogs);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        //+כלבים שלו שליפת משתמש
        public UserDetailsView GetUserWithDogs(string usereMail, string password)
        {
            //  Entities context = new Entities();


            //  var User = context.UsersTbl
            //.Where(user => user.UserEmail == usereMail && user.UserPaswrd == password).FirstOrDefault();


            //  if (User != null)
            //  {
            //      userDetails = new UserDetailsView();

            //      userDetails.UserFirstName = User.UserFirstName;
            //      userDetails.UserLastName = User.UserLastName;
            //      userDetails.UserEmail = User.UserEmail;
            //      userDetails.UserID = User.UserID;
            //      userDetails.UserPhone2 = User.UserPhone2;
            //      userDetails.UserPhone1 = User.UserPhone1;
            //      userDetails.UserComments = User.UserComments;
            //      userDetails.UserCityName = User.UserCity;
            //      userDetails.UserAddress = User.UserAddress;
            //      var dogs = context.UserDogs
            //                      .Where(userDog => userDog.DogUserID == User.UserID).Count();
            //      userDetails.DogsNumber = dogs;

            //      var reservations = context.OrdersTbl
            //                   .Where(userres => userres.OrderUserId == User.UserID).Count();
            //      userDetails.ReservationsNumber = context.OrdersTbl.Count();
            try
            {
                UserDetailsView userDetails = GetUser(usereMail, password);

                GetUserDogs(userDetails); //שליפת כלבים למשתמש

                //   HttpContext.Current.Session["userDetails"] = userDetails;



                return(userDetails);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        //עדכון משתמש
        public void UpdateUserDetails(UserDetailsView userDetails)

        {
            try
            {
                using (Entities context = new Entities())
                {
                    var user = context.Set <UsersTbl>().Find(userDetails.UserID);
                    userDetails.UserPaswrd = user.UserPaswrd;

                    //
                    //{
                    veterinarService     veterinarService = new veterinarService();
                    VeterinarDetailsView vet = veterinarService.GetVet(userDetails.VeterinarName, userDetails.VeterinarPhone1);
                    if (vet == null) //אם עדין אין במאגר וטרינר כזה
                    {
                        veterinarTbl veterinarTbl = new veterinarTbl();
                        veterinarTbl.VeterinarAddress = userDetails.VeterinarAddress;
                        veterinarTbl.VeterinarCity    = userDetails.VeterinarCity;
                        veterinarTbl.VeterinarEmail   = userDetails.VeterinarEmail;
                        veterinarTbl.VeterinarName    = userDetails.VeterinarName;
                        veterinarTbl.VeterinarPhone1  = userDetails.VeterinarPhone1;

                        context.veterinarTbl.Add(veterinarTbl);
                        context.SaveChanges();
                        // vet = veterinarService.GetVet(userDetails.VeterinarName, userDetails.VeterinarPhone1);
                        //userDetails.UserVeterinarId = vet.VeterinarId;
                    }
                    //}
                    //if (user.UserVeterinarId != userDetails.UserVeterinarId) //שינה את הוטרינר
                    //{
                    vet = veterinarService.GetVet(userDetails.VeterinarName, userDetails.VeterinarPhone1);
                    userDetails.UserVeterinarId = vet.VeterinarId;
                    //}

                    context.Entry(user).CurrentValues.SetValues(userDetails);
                    context.SaveChanges();
                }
            }
            catch (SqlException ex)
            { throw ex; }
            finally
            {  }
        }
Beispiel #6
0
        public UserDetailsView GetUserOrders(int UserID)
        {
            UserDetailsView userDetails = new UserDetailsView();

            //   שליפת כל ההזמנות מטבלתOrdersTbl
            try
            {
                Userservice userservice = new Userservice();
                userDetails = userservice.GetUser(UserID);
                OrdersForUserView ordersForUserView = GetUserOrdersList(UserID);
                userDetails.UserReservations = ordersForUserView.UserReservations;

                return(userDetails);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        private static UserDetailsView getUserDetails(Entities context, UsersTbl User)
        {
            try
            {
                UserDetailsView userDetails = new UserDetailsView();
                userDetails.DaysSumForDiscount = User.DaysSumForDiscount;
                userDetails.Acceptmessages     = User.Acceptmessages;
                userDetails.UserFirstName      = User.UserFirstName;
                userDetails.UserLastName       = User.UserLastName;
                userDetails.UserEmail          = User.UserEmail;
                userDetails.UserID             = User.UserID;
                userDetails.UserPhone2         = User.UserPhone2;
                userDetails.UserPhone1         = User.UserPhone1;
                userDetails.UserComments       = User.UserComments;
                userDetails.UserCity           = User.UserCity;
                userDetails.UserAddress        = User.UserAddress;
                userDetails.UserName           = User.UserName;
                userDetails.UserStatusCode     = User.UserStatusCode;
                var vet = context.veterinarTbl
                          .Where(v => v.VeterinarId == User.UserVeterinarId).FirstOrDefault();
                userDetails.UserVeterinarId  = User.UserVeterinarId;
                userDetails.VeterinarAddress = vet.VeterinarAddress;
                userDetails.VeterinarCity    = vet.VeterinarCity;
                userDetails.VeterinarEmail   = vet.VeterinarEmail;
                userDetails.VeterinarName    = vet.VeterinarName;
                userDetails.VeterinarPhone1  = vet.VeterinarPhone1;

                var dogs = context.UserDogs
                           .Where(userDog => userDog.DogUserID == User.UserID && userDog.DogStatus == 21).Count();
                userDetails.DogsNumber = dogs;

                var reservations = context.OrdersTbl
                                   .Where(userres => userres.OrderUserId == User.UserID).Count();
                userDetails.ReservationsNumber = context.OrdersTbl.Count();

                //HttpContext.Current.Session["userDetails"] = userDetails;
                return(userDetails);
            }
            catch (Exception ex)
            { throw ex; }
        }
Beispiel #8
0
        //שליפת כלבים למשתמש
        private void GetUserDogs(UserDetailsView userDetails)


        {
            try
            {
                Entities context = new Entities();
                var      dogs    = context.UserDogs.Where(p => p.DogUserID == userDetails.UserID && p.DogStatus == 21);
                if (dogs != null)
                {
                    userDetails.UserarrayDogs = new List <DogDetailsView>();
                    foreach (var dog in dogs)
                    {
                        DogDetailsView dogDetails = new DogDetailsView();
                        dogDetails.DogNumber        = dog.DogNumber;
                        dogDetails.DogName          = dog.DogName;
                        dogDetails.DogImage         = dog.DogImage;
                        dogDetails.DogShvav         = dog.DogShvav;
                        dogDetails.DogType          = dog.DogType;
                        dogDetails.DogStatus        = dog.DogStatus;
                        dogDetails.DogComments      = dog.DogComments;
                        dogDetails.DogUserID        = dog.DogUserID;
                        dogDetails.DogBirthDate     = dog.DogBirthDate;
                        dogDetails.DogRabiesVaccine = dog.DogRabiesVaccine;
                        dogDetails.DogNeuter        = dog.DogNeuter;
                        dogDetails.DogJump          = (bool)dog.DogJump;
                        dogDetails.DogDig           = (bool)dog.DogDig;
                        dogDetails.DogGender        = dog.DogGender;
                        dogDetails.DogFriendlyWith  = (int)dog.DogFriendlyWith;

                        userDetails.UserarrayDogs.Add(dogDetails);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #9
0
        //שליפת משתמש
        public UserDetailsView GetUser(string usereMail, string password)
        {
            try
            {
                UserDetailsView userDetails = null;

                Entities context = new Entities();


                var User = context.UsersTbl
                           .Where(user => user.UserEmail == usereMail && user.UserPaswrd == password && user.UserStatusCode != 22).FirstOrDefault();


                if (User != null)
                {
                    userDetails = getUserDetails(context, User);
                }
                return(userDetails);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        private bool checkCityExist(UserDetailsView user, string City)
        {
            XmlService xmlService = new XmlService();

            return(!xmlService.CheckCity(City));
        }
Beispiel #11
0
        private bool checkUserExist(UserDetailsView user, string mail)
        {
            Userservice userservice = new Userservice();

            return(!userservice.GetUserByMail(mail));
        }
Beispiel #12
0
        //הוספת משתמש
        public void InsertUserDetails(UserDetailsView userDetails)

        {
            try
            {
                using (Entities context = new Entities())
                {
                    UsersTbl usersTbl = new UsersTbl();
                    usersTbl.UserAddress        = userDetails.UserAddress;
                    usersTbl.UserCity           = userDetails.UserCity;
                    usersTbl.UserComments       = userDetails.UserComments;
                    usersTbl.UserEmail          = userDetails.UserEmail;
                    usersTbl.UserFirstName      = userDetails.UserFirstName;
                    usersTbl.UserLastName       = userDetails.UserLastName;
                    usersTbl.UserPaswrd         = userDetails.UserPaswrd;
                    usersTbl.UserPhone1         = userDetails.UserPhone1;
                    usersTbl.UserPhone2         = userDetails.UserPhone2;
                    usersTbl.UserStatusCode     = 21;
                    usersTbl.UserName           = userDetails.UserName;
                    usersTbl.Acceptmessages     = userDetails.Acceptmessages;
                    usersTbl.DaysSumForDiscount = 0;
                    //int vet = GetVetID(userDetails.VeterinarName, userDetails.VeterinarPhone1);
                    //if (vet == 0) //אם עדין אין במאגר וטרינר כזה
                    //{
                    //    veterinarTbl veterinarTbl = new veterinarTbl();
                    //    veterinarTbl.VeterinarAddress = userDetails.VeterinarAddress;
                    //    veterinarTbl.VeterinarCity = userDetails.VeterinarCity;
                    //    veterinarTbl.VeterinarEmail = userDetails.VeterinarEmail;
                    //    veterinarTbl.VeterinarName = userDetails.VeterinarName;
                    //    veterinarTbl.VeterinarPhone1 = userDetails.VeterinarPhone1;

                    //    context.veterinarTbl.Add(veterinarTbl);
                    //    context.SaveChanges();

                    //}
                    veterinarService veterinarService = new veterinarService();

                    VeterinarDetailsView vet = veterinarService.GetVet(userDetails.VeterinarName, userDetails.VeterinarPhone1);
                    if (vet != null)
                    {
                        usersTbl.UserVeterinarId = vet.VeterinarId;
                    }
                    else
                    {
                        veterinarTbl veterinarTbl = new veterinarTbl();
                        veterinarTbl.VeterinarAddress = userDetails.VeterinarAddress;
                        veterinarTbl.VeterinarCity    = userDetails.VeterinarCity;
                        veterinarTbl.VeterinarEmail   = userDetails.VeterinarEmail;
                        veterinarTbl.VeterinarName    = userDetails.VeterinarName;
                        veterinarTbl.VeterinarPhone1  = userDetails.VeterinarPhone1;

                        context.veterinarTbl.Add(veterinarTbl);
                        context.SaveChanges();
                        vet = veterinarService.GetVet(userDetails.VeterinarName, userDetails.VeterinarPhone1);
                        usersTbl.UserVeterinarId = vet.VeterinarId;
                    }
                    context.UsersTbl.Add(usersTbl);
                    context.SaveChanges();
                }
            }
            catch (SqlException ex)
            { throw ex; }
        }