Esempio n. 1
0
        public int?ChangeStatusPhases(List <OfferPhases> ofertas)
        {
            int?rta = null;
            OfferUserRepository <OfferUser> OfferUrepo = new OfferUserRepository <OfferUser>();
            //if (status == StatusPhase.Aplicada)
            //if (!OfferUrepo.HaveOfferUsers(offerPhases.FirstOrDefault().IdOffer) && status==StatusPhase.Aplicada )
            //{
            OfferPhasesRepository <OfferPhases> OfferPrepo = new OfferPhasesRepository <OfferPhases>();
            int  i        = 0;
            bool finaliza = false;

            foreach (var offerphase in ofertas)
            {
                int countnofini = ofertas.Count(e => e.StatusPhase != StatusPhase.Finalizada);
                if (finaliza && countnofini > 0)
                {
                    offerphase.StatusPhase = StatusPhase.EnCurso;
                }
                rta = OfferPrepo.Update(offerphase);


                if (rta == null)
                {
                    break;
                }
                if (offerphase.StatusPhase == StatusPhase.Finalizada)
                {
                    i       += 1;
                    finaliza = true;
                }
            }


            if (i == ofertas.Count & finaliza)
            {
                SProject spro  = new SProject();
                var      lista = spro.GetList(new { IdOffer = ofertas.FirstOrDefault().IdOffer });
                if (lista.Count > 0)
                {
                    var project = lista.FirstOrDefault();
                    project.Status = StatusProject.Finalizada;
                    spro.Update(project);
                    Business.Log4NetLogger logger2 = new Business.Log4NetLogger();

                    logger2.Info("Proyecto finalizado:" + project.IdOffer + "," + "Categoria:" + project.Category);
                }

                //var project= spro.GetList(new {IdOffer= ofertas.FirstOrDefault().IdOffer }).FirstOrDefault();
            }
            //}
            return(rta);
        }
Esempio n. 2
0
        public List <Project> GetListPaged(int pagenumber, int itemsperpage, string conditions, string order)
        {
            ZonaFl.Persistence.Repository.ProjectRepository <Project> Projectrepo = new ProjectRepository <Project>();
            OfferUserRepository <OfferUser>   OfferrepoUser   = new OfferUserRepository <OfferUser>();
            OfferPhasRepository <OfferPhases> OfferrepoPhases = new OfferPhasRepository <OfferPhases>();
            UserRepository userrepo = new UserRepository();
            var            lista    = Projectrepo.GetListPaged <Project, Offer>(pagenumber, itemsperpage, conditions, order).ToList().Select(e => new Project().InjectFrom(e)).Cast <Project>().ToList();

            foreach (var project in lista)
            {
                var repoofferuser   = OfferrepoUser.GetList("where idoffer=" + project.IdOffer + " and iduser='******'").ToList();
                var repoofferphases = OfferrepoPhases.GetList("where idoffer=" + project.IdOffer).ToList();
                var user            = userrepo.FindByID(new Guid(repoofferuser.FirstOrDefault().IdUser));
                project.Offer.OfferUsers  = new List <OfferUser>();
                project.Offer.OfferUsers  = repoofferuser;
                project.Offer.AspNetUser  = new AspNetUsers();
                project.Offer.AspNetUser  = user;
                project.Offer.OfferPhases = new List <OfferPhases>();
                project.Offer.OfferPhases = repoofferphases;
            }

            return(lista);
        }
Esempio n. 3
0
        public int?ChangeStatusPhases(ICollection <OfferPhases> offerPhases, Persistence.Entities.StatusPhase status, Persistence.Entities.Offer offer)
        {
            int?rta = null;
            OfferUserRepository <OfferUser> OfferUrepo = new OfferUserRepository <OfferUser>();
            OfferRepository <Offer>         Offerrepo  = new OfferRepository <Offer>();
            //if (status == StatusPhase.Aplicada)
            //if (!OfferUrepo.HaveOfferUsers(offerPhases.FirstOrDefault().IdOffer) && status==StatusPhase.Aplicada )
            //{
            OfferPhasesRepository <OfferPhases> OfferPrepo = new OfferPhasesRepository <OfferPhases>();

            offer.Status = Offer.StatusOffer.Eliminada;
            Offerrepo.Update(offer);
            foreach (var offerphase in offerPhases)
            {
                offerphase.StatusPhase = status;
                rta = OfferPrepo.Update(offerphase);
                if (status == StatusPhase.Finalizada)
                {
                    Business.Log4NetLogger logger2 = new Business.Log4NetLogger();

                    logger2.Info("Proyecto finalizado:" + offerphase.IdOffer);
                }
                else if (status == StatusPhase.Eliminada)
                {
                    Business.Log4NetLogger logger2 = new Business.Log4NetLogger();

                    logger2.Info("Proyecto eliminado:" + offerphase.IdOffer);
                }
                if (rta == null)
                {
                    break;
                }
            }
            //}
            return(rta);
        }
Esempio n. 4
0
        public int?InsertUserOffer(int idoffer, string iduser, bool sendemail)
        {
            OfferUserRepository <OfferUser>     OfferUrepo = new OfferUserRepository <OfferUser>();
            OfferPhasesRepository <OfferPhases> OfferPrepo = new OfferPhasesRepository <OfferPhases>();
            ProjectRepository <Project>         Offerrepo  = new ProjectRepository <Project>();

            if (OfferUrepo.GetOfferUser(idoffer, iduser) == null)
            {
                OfferUrepo.InsertUserOffer(idoffer, iduser);
            }
            else
            {
                return(-1);
            }


            List <OfferPhases> lista = OfferPrepo.GetPhasesByIdOffer(idoffer).ToList();
            var   offer       = GetById(idoffer);
            SUser suser       = new SUser();
            var   contratante = suser.GetUserById(new Guid(offer.IdUser));
            var   aplicante   = suser.GetUserById(new Guid(iduser));

            //if (Offerrepo.GetByOffer(idoffer) == null)
            //{
            //    Project project = new Project();
            //    project.IdOffer = idoffer;
            //    project.IdCategory = offer.CategoryId;
            //    project.Postulantes = offer.OfferUsers.Count + 1;
            //    project.Qualification = 0;
            //    project.Status = Persistence.Entities.StatusPhase.Publicada;
            //    Offerrepo.Insert(project);
            //}



            if (sendemail && ChangeStatusPhases(lista, StatusPhase.EnCurso, offer) != -1)
            {
                string Url  = "http://zonafl.com/Static/index.html#iniciar";
                string body = "El Usuario," + aplicante.UserName;
                body += " ha aplicado al proyecto " + offer.TitleOffer;
                body += " favor ingresar <a href = '" + Url + "'>aqui para ingresar al sitio.</a>";
                body += "<br /><br />Gracias";


                var smail = SMail.Instance;


                smail.Send("*****@*****.**", contratante.Email, "Usuario Aplicó proyecto", body);
            }
            else
            {
                return(-1);
            }
            return(1);

            Log4NetLogger logger2 = new Log4NetLogger();


            var user = suser.GetUserById(new Guid(iduser));

            logger2.Info("Postulación Oferta:" + idoffer + "," + "UsuarioOrigen:" + user.UserName);
            //Offerrepo.Insert()
        }
Esempio n. 5
0
        public void Connect(string userName, string email, Microsoft.AspNet.SignalR.Hubs.IHubCallerConnectionContext <dynamic> Clients2, string id)
        {
            emailIDLoaded = email;
            //var id = Context.ConnectionId;
            //using (DB_102707_zonaflEntities dc = new DB_102707_zonaflEntities())
            //{
            ChatUserDetailRepository <ChatUserDetail> chatud = new ChatUserDetailRepository <ChatUserDetail>();
            OfferRepository <Offer>           offerrepo      = new OfferRepository <Offer>();
            OfferUserRepository <OfferUser>   offeurrepo     = new OfferUserRepository <OfferUser>();
            OfferUserRepository <AspNetUsers> userrepo       = new OfferUserRepository <AspNetUsers>();
            ChatUserDetail item = chatud.GetList(new { EmailID = email }).FirstOrDefault();

            //ChatUserDetail item=chatud.GetList("where EmailID='" + email+"'").FirstOrDefault();
            //var item = dc.ChatUserDetails.FirstOrDefault(x => x.EmailID == email);
            if (item != null)
            {
                chatud.Delete(item.Id);
                //dc.ChatUserDetails.Remove(item);
                //dc.SaveChanges();

                // Disconnect
                Clients2.All.onUserDisconnectedExisting(item.ConnectionId, item.UserName);
            }



            AspNetUsers user = userrepo.GtUserByEmail(email);

            if (chatud.GetList(new { EmailId = user.Email }).FirstOrDefault() == null)
            {
                var userdetails = new ChatUserDetail
                {
                    ConnectionId = id,
                    UserName     = userName,
                    EmailID      = email
                };
                chatud.Insert(userdetails);
            }

            List <ChatUserDetail> Users = new List <ChatUserDetail>();

            if (!user.Freelance)
            {
                List <Offer> offertsuser = offerrepo.GetOffertsByContractorEmail(email);
                string       valueoffer  = string.Join(",", offertsuser.Select(e => e.Id).ToArray());
                Users = chatud.GetUsersByOfferContractorid(valueoffer);
            }
            else
            {
                List <OfferUser> offertsuser = offeurrepo.GetOffersUser(user.Id);
                string           valueoffer  = string.Join(",", offertsuser.Select(e => e.IdOffer).ToArray());
                Users = chatud.GetContractorsByOffers(valueoffer);
            }

            //var Users = chatud.GetList().ToList();
            if (Users.Where(x => x.EmailID == email).ToList().Count == 0)
            {
                //var userdetails = new ChatUserDetail
                //{
                //    ConnectionId = id,
                //    UserName = userName,
                //    EmailID = email
                //};
                //chatud.Insert(userdetails);
                //dc.SaveChanges();

                // send to caller
                var connectedUsers = chatud.GetList();
                ChatMessageDetailRepository <ChatMessageDetail> chatmd = new ChatMessageDetailRepository <ChatMessageDetail>();
                var CurrentMessage = chatmd.GetList();//dc.ChatMessageDetails.ToList();
                Clients2.Caller.onConnected(id, userName, connectedUsers, CurrentMessage);
                // }

                // send to all except caller client
                Clients2.AllExcept(id).onNewUserConnected(id, userName, email);
            }
        }