Beispiel #1
0
        public void OylamaMesajGonder(Guid OylamaSahibiId, Guid OylamaId, Guid BahsedenId, string Mesaj, List <VotedressUser_sade> Bahsedilenler)
        {
            MessangerManager messangerManager = new MessangerManager();

            BlockedUserManager blockedUserManager = new BlockedUserManager();


            bool banlimi = blockedUserManager.EngelKontrol(BahsedenId, OylamaSahibiId);

            if (banlimi == true)
            {
                Clients.Caller.Engelli();
            }
            else
            {
                VoteMessageManager voteMessage_manager = new VoteMessageManager();
                VoteMessage_sade   sonuc_Mesaj         = voteMessage_manager.OylamaMesajEkle(BahsedenId, OylamaId, Mesaj);

                Clients.Group(OylamaId.ToString()).OylamaMesajGonder(sonuc_Mesaj);

                VotedressUserDetailManager userdetailManager = new VotedressUserDetailManager();

                UserDetail oylamaSahibi = userdetailManager.GetUserDetail(OylamaSahibiId);



                UserDetail         bahseden = userdetailManager.GetUserDetail(BahsedenId);
                VotedressUser_sade serialize_hatasindan_bahseden = new VotedressUser_sade();
                serialize_hatasindan_bahseden.id           = bahseden.UserId;
                serialize_hatasindan_bahseden.Name         = bahseden.Name;
                serialize_hatasindan_bahseden.SurName      = bahseden.SurName;
                serialize_hatasindan_bahseden.ProfileImage = bahseden.User.ProfileImage;
                serialize_hatasindan_bahseden.Sex          = bahseden.Sex;
                serialize_hatasindan_bahseden.SocialName   = bahseden.User.SocialName;
                serialize_hatasindan_bahseden.SocialId     = bahseden.User.SocialId;
                serialize_hatasindan_bahseden.Email        = bahseden.User.Email;
                serialize_hatasindan_bahseden.Birthday     = bahseden.Birthday;

                string            conId;
                BahsedilenManager bahsedilenManager = new BahsedilenManager();
                for (int i = 0; i < Bahsedilenler.Count; i++)
                {
                    Bahsedilen eklenen = bahsedilenManager.BahsedilenEkleOylama(OylamaId, BahsedenId, Bahsedilenler[i].id, Mesaj);

                    Bahsedilen_sade gidecek = new Bahsedilen_sade()
                    {
                        Bahseden         = serialize_hatasindan_bahseden,
                        BahsetmeTarihi   = eklenen.BahsedilmeTarihi,
                        GorulmeDurumu    = eklenen.GorulmeDurumu,
                        bahsedilenYerAdi = oylamaSahibi.Name + " " + oylamaSahibi.SurName,
                        Mesaj            = eklenen.Mesaj,
                        TipId            = OylamaId,
                        Tip = "oylama"
                    };

                    conId = messangerManager.ConnectionIdGetir(Bahsedilenler[i].id);
                    Clients.Client(conId).SizdenBahsedildi(gidecek);
                }
            };
        }
        public VoteMessage_sade OylamaMesajEkle(Guid gonderen_id, Guid oylama_id, string mesaj)
        {
            VotedressUser user = unitOfWork.Repository <VotedressUser>().Find(x => x.id == gonderen_id);
            Vote          vote = unitOfWork.Repository <Vote>().Find(x => x.id == oylama_id);

            VoteMessage voteMessage = new VoteMessage();

            voteMessage.Message        = mesaj;
            voteMessage.User           = user;
            voteMessage.Vote           = vote;
            voteMessage.GondermeTarihi = DateTime.Now;

            unitOfWork.Repository <VoteMessage>().Insert(voteMessage);
            unitOfWork.SaveChanges();



            VoteMessage_sade voteMessage_sade = new VoteMessage_sade();

            voteMessage_sade.id             = voteMessage.id;
            voteMessage_sade.GondermeTarihi = voteMessage.GondermeTarihi;
            voteMessage_sade.Message        = voteMessage.Message;

            voteMessage_sade.MesajSahibi.id           = user.id;
            voteMessage_sade.MesajSahibi.Name         = user.UserDetail.Name;
            voteMessage_sade.MesajSahibi.ProfileImage = user.ProfileImage;
            voteMessage_sade.MesajSahibi.Sex          = user.UserDetail.Sex;
            voteMessage_sade.MesajSahibi.SocialId     = user.SocialId;
            voteMessage_sade.MesajSahibi.SocialName   = user.SocialName;
            voteMessage_sade.MesajSahibi.SurName      = user.UserDetail.SurName;
            voteMessage_sade.MesajSahibi.Email        = user.Email;
            voteMessage_sade.MesajSahibi.Birthday     = user.UserDetail.Birthday;

            return(voteMessage_sade);
        }
        public OylamalarimViewModel OylamalarimSayfasi(Guid kullanici_id)
        {
            List <Vote> oylama = OylamalarimiGetir(kullanici_id);

            if (oylama.Count != 0)
            {
                DateTime enBuyukTarih = oylama.Max(x => x.StartTime);
                Vote     vote         = oylama.Where(x => x.StartTime == enBuyukTarih).FirstOrDefault();


                if (oylama.Count != 0)
                {
                    Vote_sade vote_sade = new Vote_sade();

                    vote_sade.id = vote.id;
                    vote_sade.PaylasimaAcikmi  = vote.PaylasimaAcikmi;
                    vote_sade.ProfilGorunsunMu = vote.ProfilGorunsunMu;
                    vote_sade.StartTime        = vote.StartTime;
                    vote_sade.TypeOfVote       = vote.TypeOfVote;
                    vote_sade.VoteLink         = vote.VoteLink;
                    vote_sade.FinishTime       = vote.FinishTime;


                    vote_sade.OylamaUrunleri = vote.VoteProduct.Select(x => new VoteProduct_sade()
                    {
                        id               = x.id,
                        ProductId        = x.Product.id,
                        ProductName      = x.Product.ProductName,
                        ProductImage     = x.Product.ProductImage,
                        Price            = x.Product.Price,
                        IsForSale        = x.Product.IsForSale,
                        VoteCount        = x.VoteCount,
                        LongDescription  = x.Product.LongDescription,
                        ShortDescription = x.Product.ShortDescription,
                        UrunSahibi       = new Magazalar_sade()
                        {
                            MagazaGuid          = x.Product.User.id,
                            SirketAdi           = x.Product.User.UserDetail.CompanyName,
                            SirketResmi         = x.Product.User.ProfileImage,
                            TelNo               = x.Product.User.UserDetail.PhoneNumber,
                            Email               = x.Product.User.Email,
                            WebSite             = "www.deneme.com",
                            MagazadakilerSayisi = x.Product.User.OnlineCount,
                            Sehir               = x.Product.User.UserDetail.City.CityName,
                            Ilce          = x.Product.User.UserDetail.County.CountyName,
                            Mahalle       = x.Product.User.UserDetail.Neighborhood.NeighborhoodName,
                            Adres         = x.Product.User.UserDetail.AdressDetail,
                            FranchiseAdi  = x.Product.User.Franchise.FranchiseName,
                            FranchiseLogo = x.Product.User.Franchise.FranchiseLogo,
                        },

                        OylamaResimleri = x.VoteImages.Select(t => new VoteImage_sade()
                        {
                            id        = t.id,
                            Aciklama  = t.Aciklama,
                            ImageNo   = t.ImageNo,
                            ImagePath = t.ImagePath
                        }).ToList()
                    }).ToList();

                    vote_sade.OylamaSahibi.id           = vote.User.id;
                    vote_sade.OylamaSahibi.Name         = vote.User.UserDetail.Name;
                    vote_sade.OylamaSahibi.SurName      = vote.User.UserDetail.SurName;
                    vote_sade.OylamaSahibi.Email        = vote.User.Email;
                    vote_sade.OylamaSahibi.Birthday     = vote.User.UserDetail.Birthday;
                    vote_sade.OylamaSahibi.Sex          = vote.User.UserDetail.Sex;
                    vote_sade.OylamaSahibi.ProfileImage = vote.User.ProfileImage;
                    vote_sade.OylamaSahibi.SocialId     = vote.User.SocialId;
                    vote_sade.OylamaSahibi.SocialName   = vote.User.SocialName;



                    if (vote.VoteMessage != null)
                    {
                        VoteMessage_sade voteMessage_sade;
                        for (int i = 0; i < vote.VoteMessage.Count; i++)
                        {
                            voteMessage_sade = new VoteMessage_sade();

                            voteMessage_sade.id             = vote.VoteMessage[i].id;
                            voteMessage_sade.Message        = vote.VoteMessage[i].Message;
                            voteMessage_sade.GondermeTarihi = vote.VoteMessage[i].GondermeTarihi;

                            voteMessage_sade.MesajSahibi.id           = vote.VoteMessage[i].User.id;
                            voteMessage_sade.MesajSahibi.Name         = vote.VoteMessage[i].User.UserDetail.Name;
                            voteMessage_sade.MesajSahibi.ProfileImage = vote.VoteMessage[i].User.ProfileImage;
                            voteMessage_sade.MesajSahibi.Sex          = vote.VoteMessage[i].User.UserDetail.Sex;
                            voteMessage_sade.MesajSahibi.SocialId     = vote.VoteMessage[i].User.SocialId;
                            voteMessage_sade.MesajSahibi.SocialName   = vote.VoteMessage[i].User.SocialName;
                            voteMessage_sade.MesajSahibi.SurName      = vote.VoteMessage[i].User.UserDetail.SurName;
                            voteMessage_sade.MesajSahibi.Email        = vote.VoteMessage[i].User.Email;
                            voteMessage_sade.MesajSahibi.Birthday     = vote.VoteMessage[i].User.UserDetail.Birthday;

                            vote_sade.OylamaMesajlari.Add(voteMessage_sade);
                        }
                    }

                    InVoteChatManager invotechatManager = new InVoteChatManager();
                    vote_sade.Chattekiler   = invotechatManager.ChattekileriGetir(vote.id);
                    vote_sade.SessionUserId = kullanici_id;

                    OylamalarimViewModel oylamalarimViewModel = new OylamalarimViewModel();
                    oylamalarimViewModel.vote_Sade         = vote_sade;
                    oylamalarimViewModel.oylamalarimModels = oylama.OrderByDescending(x => x.StartTime).Select(x => new OylamalarimModel()
                    {
                        OylamaId = x.id,
                        OylamaBaslangicZamani = x.StartTime,
                        OylamaBitisZamani     = x.FinishTime,
                        OylamaDurumu          = x.FinishTime < DateTime.Now ? true : false
                    }).ToList();

                    return(oylamalarimViewModel);
                }
            }
            return(null);
        }
        public Vote_sade OylamaGetirOylamakIcin(Guid kullanici_id)
        {
            List <Vote> oylamalar     = unitOfWork.Repository <Vote>().List();
            List <Guid> oyverdiklerim = unitOfWork.Repository <MyVoted>().List(x => x.User.id == kullanici_id).Select(x => x.Vote.id).ToList();

            DateTime    tarih  = DateTime.Now;
            List <Vote> oylama = (from p in oylamalar where !oyverdiklerim.Contains(p.id) && p.FinishTime >= tarih && p.User.id != kullanici_id && p.TypeOfVote == "genel" select p).ToList();


            if (oylama.Count != 0)
            {
                int en_kucuk = oylama.Min(x => x.Counter);

                Vote oylama2 = oylama.Where(x => x.Counter == en_kucuk).FirstOrDefault();

                oylama2.Counter = oylama2.Counter + 1;

                unitOfWork.Repository <Vote>().Update(oylama2);
                unitOfWork.SaveChanges();

                Vote_sade vote_sade = new Vote_sade();

                vote_sade.id = oylama2.id;
                vote_sade.PaylasimaAcikmi  = oylama2.PaylasimaAcikmi;
                vote_sade.ProfilGorunsunMu = oylama2.ProfilGorunsunMu;
                vote_sade.StartTime        = oylama2.StartTime;
                vote_sade.TypeOfVote       = oylama2.TypeOfVote;
                vote_sade.VoteLink         = oylama2.VoteLink;
                vote_sade.FinishTime       = oylama2.FinishTime;


                vote_sade.OylamaUrunleri = oylama2.VoteProduct.Select(x => new VoteProduct_sade()
                {
                    id               = x.id,
                    ProductId        = x.Product.id,
                    ProductName      = x.Product.ProductName,
                    ProductImage     = x.Product.ProductImage,
                    Price            = x.Product.Price,
                    IsForSale        = x.Product.IsForSale,
                    VoteCount        = x.VoteCount,
                    LongDescription  = x.Product.LongDescription,
                    ShortDescription = x.Product.ShortDescription,
                    UrunSahibi       = new Magazalar_sade()
                    {
                        MagazaGuid          = x.Product.User.id,
                        SirketAdi           = x.Product.User.UserDetail.CompanyName,
                        SirketResmi         = x.Product.User.ProfileImage,
                        TelNo               = x.Product.User.UserDetail.PhoneNumber,
                        Email               = x.Product.User.Email,
                        WebSite             = "www.deneme.com",
                        MagazadakilerSayisi = x.Product.User.OnlineCount,
                        Sehir               = x.Product.User.UserDetail.City.CityName,
                        Ilce          = x.Product.User.UserDetail.County.CountyName,
                        Mahalle       = x.Product.User.UserDetail.Neighborhood.NeighborhoodName,
                        Adres         = x.Product.User.UserDetail.AdressDetail,
                        FranchiseAdi  = x.Product.User.Franchise.FranchiseName,
                        FranchiseLogo = x.Product.User.Franchise.FranchiseLogo,
                    },

                    OylamaResimleri = x.VoteImages.Select(t => new VoteImage_sade()
                    {
                        id        = t.id,
                        Aciklama  = t.Aciklama,
                        ImageNo   = t.ImageNo,
                        ImagePath = t.ImagePath
                    }).ToList()
                }).ToList();

                vote_sade.OylamaSahibi.id           = oylama2.User.id;
                vote_sade.OylamaSahibi.Name         = oylama2.User.UserDetail.Name;
                vote_sade.OylamaSahibi.SurName      = oylama2.User.UserDetail.SurName;
                vote_sade.OylamaSahibi.Email        = oylama2.User.Email;
                vote_sade.OylamaSahibi.Birthday     = oylama2.User.UserDetail.Birthday;
                vote_sade.OylamaSahibi.Sex          = oylama2.User.UserDetail.Sex;
                vote_sade.OylamaSahibi.ProfileImage = oylama2.User.ProfileImage;
                vote_sade.OylamaSahibi.SocialId     = oylama2.User.SocialId;
                vote_sade.OylamaSahibi.SocialName   = oylama2.User.SocialName;



                if (oylama2.VoteMessage != null)
                {
                    VoteMessage_sade voteMessage_sade;
                    for (int i = 0; i < oylama2.VoteMessage.Count; i++)
                    {
                        voteMessage_sade = new VoteMessage_sade();

                        voteMessage_sade.id             = oylama2.VoteMessage[i].id;
                        voteMessage_sade.Message        = oylama2.VoteMessage[i].Message;
                        voteMessage_sade.GondermeTarihi = oylama2.VoteMessage[i].GondermeTarihi;

                        voteMessage_sade.MesajSahibi.id           = oylama2.VoteMessage[i].User.id;
                        voteMessage_sade.MesajSahibi.Name         = oylama2.VoteMessage[i].User.UserDetail.Name;
                        voteMessage_sade.MesajSahibi.ProfileImage = oylama2.VoteMessage[i].User.ProfileImage;
                        voteMessage_sade.MesajSahibi.Sex          = oylama2.VoteMessage[i].User.UserDetail.Sex;
                        voteMessage_sade.MesajSahibi.SocialId     = oylama2.VoteMessage[i].User.SocialId;
                        voteMessage_sade.MesajSahibi.SocialName   = oylama2.VoteMessage[i].User.SocialName;
                        voteMessage_sade.MesajSahibi.SurName      = oylama2.VoteMessage[i].User.UserDetail.SurName;
                        voteMessage_sade.MesajSahibi.Email        = oylama2.VoteMessage[i].User.Email;
                        voteMessage_sade.MesajSahibi.Birthday     = oylama2.VoteMessage[i].User.UserDetail.Birthday;

                        vote_sade.OylamaMesajlari.Add(voteMessage_sade);
                    }
                }

                InVoteChatManager invotechatManager = new InVoteChatManager();
                vote_sade.Chattekiler = invotechatManager.ChattekileriGetir(oylama2.id);



                vote_sade.SessionUserId = kullanici_id;
                return(vote_sade);
            }

            return(null);
        }
        public Vote_sade OylamaGetir(Guid oylamaId, Guid userId)
        {
            Vote vote = unitOfWork.Repository <Vote>().Find(x => x.id == oylamaId);


            if (vote.User.id == userId)
            {
                Vote_sade vote_sade = new Vote_sade();

                vote_sade.id = vote.id;
                vote_sade.PaylasimaAcikmi  = vote.PaylasimaAcikmi;
                vote_sade.ProfilGorunsunMu = vote.ProfilGorunsunMu;
                vote_sade.StartTime        = vote.StartTime;
                vote_sade.TypeOfVote       = vote.TypeOfVote;
                vote_sade.VoteLink         = vote.VoteLink;
                vote_sade.FinishTime       = vote.FinishTime;


                vote_sade.OylamaUrunleri = vote.VoteProduct.Select(x => new VoteProduct_sade()
                {
                    id               = x.id,
                    ProductId        = x.Product.id,
                    ProductName      = x.Product.ProductName,
                    ProductImage     = x.Product.ProductImage,
                    Price            = x.Product.Price,
                    IsForSale        = x.Product.IsForSale,
                    VoteCount        = x.VoteCount,
                    LongDescription  = x.Product.LongDescription,
                    ShortDescription = x.Product.ShortDescription,
                    UrunSahibi       = new Magazalar_sade()
                    {
                        MagazaGuid          = x.Product.User.id,
                        SirketAdi           = x.Product.User.UserDetail.CompanyName,
                        SirketResmi         = x.Product.User.ProfileImage,
                        TelNo               = x.Product.User.UserDetail.PhoneNumber,
                        Email               = x.Product.User.Email,
                        WebSite             = "www.deneme.com",
                        MagazadakilerSayisi = x.Product.User.OnlineCount,
                        Sehir               = x.Product.User.UserDetail.City.CityName,
                        Ilce          = x.Product.User.UserDetail.County.CountyName,
                        Mahalle       = x.Product.User.UserDetail.Neighborhood.NeighborhoodName,
                        Adres         = x.Product.User.UserDetail.AdressDetail,
                        FranchiseAdi  = x.Product.User.Franchise.FranchiseName,
                        FranchiseLogo = x.Product.User.Franchise.FranchiseLogo,
                    },

                    OylamaResimleri = x.VoteImages.Select(t => new VoteImage_sade()
                    {
                        id        = t.id,
                        Aciklama  = t.Aciklama,
                        ImageNo   = t.ImageNo,
                        ImagePath = t.ImagePath
                    }).ToList()
                }).ToList();

                vote_sade.OylamaSahibi.id           = vote.User.id;
                vote_sade.OylamaSahibi.Name         = vote.User.UserDetail.Name;
                vote_sade.OylamaSahibi.SurName      = vote.User.UserDetail.SurName;
                vote_sade.OylamaSahibi.Email        = vote.User.Email;
                vote_sade.OylamaSahibi.Birthday     = vote.User.UserDetail.Birthday;
                vote_sade.OylamaSahibi.Sex          = vote.User.UserDetail.Sex;
                vote_sade.OylamaSahibi.ProfileImage = vote.User.ProfileImage;
                vote_sade.OylamaSahibi.SocialId     = vote.User.SocialId;
                vote_sade.OylamaSahibi.SocialName   = vote.User.SocialName;



                if (vote.VoteMessage != null)
                {
                    VoteMessage_sade voteMessage_sade;
                    for (int i = 0; i < vote.VoteMessage.Count; i++)
                    {
                        voteMessage_sade = new VoteMessage_sade();

                        voteMessage_sade.id             = vote.VoteMessage[i].id;
                        voteMessage_sade.Message        = vote.VoteMessage[i].Message;
                        voteMessage_sade.GondermeTarihi = vote.VoteMessage[i].GondermeTarihi;

                        voteMessage_sade.MesajSahibi.id           = vote.VoteMessage[i].User.id;
                        voteMessage_sade.MesajSahibi.Name         = vote.VoteMessage[i].User.UserDetail.Name;
                        voteMessage_sade.MesajSahibi.ProfileImage = vote.VoteMessage[i].User.ProfileImage;
                        voteMessage_sade.MesajSahibi.Sex          = vote.VoteMessage[i].User.UserDetail.Sex;
                        voteMessage_sade.MesajSahibi.SocialId     = vote.VoteMessage[i].User.SocialId;
                        voteMessage_sade.MesajSahibi.SocialName   = vote.VoteMessage[i].User.SocialName;
                        voteMessage_sade.MesajSahibi.SurName      = vote.VoteMessage[i].User.UserDetail.SurName;
                        voteMessage_sade.MesajSahibi.Email        = vote.VoteMessage[i].User.Email;
                        voteMessage_sade.MesajSahibi.Birthday     = vote.VoteMessage[i].User.UserDetail.Birthday;

                        vote_sade.OylamaMesajlari.Add(voteMessage_sade);
                    }
                }

                InVoteChatManager invotechatManager = new InVoteChatManager();
                vote_sade.Chattekiler   = invotechatManager.ChattekileriGetir(vote.id);
                vote_sade.SessionUserId = userId;

                return(vote_sade);
            }

            return(null);
        }