Beispiel #1
0
        //public ActionResult RegistrarOption(UserModel Data)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        ProposalBussiness ProposalLogic = new ProposalBussiness();
        //        ProposalLogi.


        //        bool existUser = false;
        //                bool valid = false;
        //                valid = RegisterUser(Data, out existUser);
        //                if (existUser)
        //                {
        //                    //si es true el usuario existe mesaje de que existe en la vista
        //                    ViewBag.ErrorUsuarioExiste = "El usuario " + Data.UserName + " ya fue registrado anteriormente";

        //                }
        //                else
        //                {
        //                    if (valid)
        //                    {
        //                        return RedirectToAction("UserList", "User");
        //                    }
        //                    else
        //                    {

        //                        ViewBag.ErrorDesconocido = "Occurió un error insertando. Por favor intentelo nuevamente.";
        //                    }
        //                }


        //    }
        //    else
        //    {
        //        return View("NewUser", Data);
        //    }
        //    return View("NewUser", Data);
        //}

        public ActionResult NewOption(string p, string n)
        {
            try
            {
                UserModel user = (UserModel)Session["User"];
                if (user == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ProposalFilter Filtro = new ProposalFilter();
                    Filtro.Email = user.Email;
                    //   Filtro.TypeVoting = 0;

                    ProposalBussiness ProposalLogic = new ProposalBussiness();

                    List <ProposalModel> ListProposal = new List <ProposalModel>();


                    NewOptionModel NewOption = new NewOptionModel();

                    NewOption.ProposalId   = p;
                    NewOption.ProposalName = n;
                    NewOption.Proposals    = ProposalLogic.SearchProposalByUser(Filtro);

                    return(View(NewOption));
                }
            }
            catch
            {
                return(View("Error"));
            }
        }
Beispiel #2
0
        public ActionResult Upload(HttpPostedFileBase file)
        {
            ProposalModel proposal = (ProposalModel)Session["Proposal"];

            if (file == null)
            {
                ViewBag.Error = "No selecciono un archivo";
                return(View("RegisterUserProposal", null));
            }

            string archivo = (DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + file.FileName).ToLower();
            string ruta    = Server.MapPath("~/Files/" + archivo);

            file.SaveAs(Server.MapPath("~/Files/" + archivo));
            if (RegistroMasivo(ruta, ((ProposalModel)Session["Proposal"]).ContracEthereumProposal, ((ProposalModel)Session["Proposal"]).ProposalName))
            {
                ViewBag.Success = "Se enviaron las invitaciones con éxito.";
                ProposalBussiness ProposalLogic = new ProposalBussiness();

                ProposalFilter Filtro = new ProposalFilter();
                UserModel      user   = (UserModel)Session["User"];
                Filtro.Email        = user.Email;
                Filtro.QuestionType = null;
                List <ProposalModel> ListProposal = new List <ProposalModel>();

                ListProposal = ProposalLogic.SearchProposalByUser(Filtro);
                return(View("ProposalList", ListProposal));
            }
            else
            {
                ViewBag.Error = "Hay Correos Invalidos";
                return(View("RegisterUserProposal", null));
            }
            //  return View("ProposalList");
        }
Beispiel #3
0
        public ActionResult Index(ProposalModel model)
        {
            List <OptionModel> lst = new List <OptionModel>();

            foreach (var item in model.SelectedOptions)
            {
                lst.Add(new OptionModel {
                    IdOption = Convert.ToInt32(item)
                });
            }

            VotesModel vote = new VotesModel {
                Email = ((UserModel)Session["User"]).Email, Options = lst, ContracEthereumProposal = Session["propId"].ToString()
            };

            ProposalBussiness propBuss = new ProposalBussiness();

            bool resp = propBuss.DoVote(vote);

            //save
            if (resp)
            {
                return(RedirectToAction("Proposal", "ProposalList"));
            }

            return(RedirectToAction("Proposal", "ProposalList"));
        }
Beispiel #4
0
        // GET: Votes
        public ActionResult Index(string id)
        {
            Session["propId"] = id;

            UserModel user = (UserModel)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ProposalFilter Filtro = new ProposalFilter();
                Filtro.Email = user.Email;
                //  Filtro.TypeVoting = 0;

                ProposalBussiness ProposalLogic = new ProposalBussiness();

                List <ProposalModel> ListProposal = new List <ProposalModel>();

                ListProposal = ProposalLogic.SearchProposalByUser(Filtro);

                ProposalModel currentProposal = ListProposal.Where(x => x.ContracEthereumProposal == id).FirstOrDefault();

                ViewBag.UserEmail = user.Email;
                return(View(currentProposal));
            }
        }
Beispiel #5
0
        public ActionResult EditSummit(ProposalModel proposal)
        {
            try
            {
                proposal.ContracEthereumProposal = ((ProposalModel)Session["Proposal"]).ContracEthereumProposal;
                proposal.QuestionType            = ((ProposalModel)Session["Proposal"]).QuestionType;
                UserModel user = (UserModel)Session["User"];

                using (ProposalDataAccess proposalDataAccess = new ProposalDataAccess())
                {
                    if (proposalDataAccess.UpdateProposal(proposal))
                    {
                        ProposalFilter Filtro = new ProposalFilter();
                        Filtro.Email = user.Email;
                        //  Filtro.TypeVoting = 0;

                        ProposalBussiness ProposalLogic = new ProposalBussiness();

                        List <ProposalModel> ListProposal = new List <ProposalModel>();

                        ListProposal = ProposalLogic.SearchProposalByUser(Filtro);

                        ViewBag.Success = "Se modificó correctamente";
                        return(View("ProposalList", ListProposal));
                    }
                    else
                    {
                        ProposalBussiness ProposalLogic = new ProposalBussiness();

                        ProposalModel Filtro = new ProposalModel();
                        Filtro.ContracEthereumProposal = proposal.ContracEthereumProposal;

                        ProposalModel CurrentProposal = new ProposalModel();

                        CurrentProposal      = ProposalLogic.SearchProposal(Filtro)[0];
                        ViewBag.SucceErrorss = "Se modificó correctamente";
                        return(View("Edit", CurrentProposal));
                    }
                }
            }
            catch
            {
                return(View("error"));
            }
        }
Beispiel #6
0
        public ActionResult Edit(string ContracEthereumProposal)
        {
            try
            {
                ProposalBussiness ProposalLogic = new ProposalBussiness();

                ProposalModel Filtro = new ProposalModel();
                Filtro.ContracEthereumProposal = ContracEthereumProposal;

                ProposalModel CurrentProposal = new ProposalModel();

                CurrentProposal     = ProposalLogic.SearchProposal(Filtro)[0];
                Session["Proposal"] = CurrentProposal;
                return(View(CurrentProposal));
            }
            catch
            {
                return(View("error"));
            }
        }
Beispiel #7
0
        public ActionResult RegisterOption(NewOptionModel Data)
        {
            try
            {
                ProposalBussiness ProposalLogic = new ProposalBussiness();

                if (ProposalLogic.InsertOption(Data.ProposalId, Data.OptionName))
                {
                    return(RedirectToAction("NewOption", "Proposal", new { p = Data.ProposalId, n = Data.ProposalName }));
                    //return RedirectToAction("ProposalList", "Proposal");
                }
                else
                {
                    return(View("error"));
                }
            }
            catch
            {
                return(View("error"));
            }
        }
Beispiel #8
0
        public ActionResult GraficVoting(string NumberContract)
        {
            try
            {
                List <ProposalModel> list = null;
                using (ProposalDataAccess proposalDataAccess = new ProposalDataAccess())
                {
                    list = proposalDataAccess.SearchProposal(NumberContract, null);
                }

                List <DataPointModel> dataPoints  = new List <DataPointModel>();
                ProposalBussiness     porpBisness = new ProposalBussiness();

                List <OptionModel> options = porpBisness.ConsultPartialResults(list[0]);
                foreach (var item in options)
                {
                    dataPoints.Add(new DataPointModel(0, item.NumberOfVotes, item.Description, item.Description + "=" + item.NumberOfVotes.ToString()));
                }

                List <VotesModel> Votes = porpBisness.SearchVotes(list[0].ContracEthereumProposal);

                string DatoSource = "[";
                foreach (DataPointModel item in dataPoints)
                {
                    string dat = " y:{0}, legendText: \"{1}\", indexLabel: \"{2}\"";
                    DatoSource += "{" + string.Format(dat, item.y.ToString(), item.legendText, item.indexLabel) + "},";
                }
                DatoSource         += "]";
                ViewBag.DataPoints  = DatoSource;// System.Web.WebPages.Html.Raw( JsonConvert.SerializeObject(dataPoints).Replace(@"""", @""));
                ViewBag.Description = "\"" + list[0].ProposalName + "\"";
                ViewBag.Proposal    = list[0];
                ViewBag.Votes       = Votes;
                return(View());
            }
            catch (Exception)
            {
                return(RedirectToAction("ProposalList", "Proposal"));
            }
        }
Beispiel #9
0
        public ActionResult Delete(string p)
        {
            try
            {
                ProposalBussiness ProposalLogic = new ProposalBussiness();

                if (ProposalLogic.DeleteProposal(new ProposalModel()
                {
                    ContracEthereumProposal = p
                }))
                {
                    return(RedirectToAction("ProposalList", "Proposal"));
                }
                else
                {
                    return(View("error"));
                }
            }
            catch
            {
                return(View("error"));
            }
        }
Beispiel #10
0
        public ActionResult ProposalList()
        {
            UserModel user = (UserModel)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ProposalFilter Filtro = new ProposalFilter();
                Filtro.Email = user.Email;
                ///  Filtro.QuestionType = EnumQuestionType.Papeleta;

                ProposalBussiness ProposalLogic = new ProposalBussiness();

                List <ProposalModel> ListProposal = new List <ProposalModel>();

                ListProposal = ProposalLogic.SearchProposalByUser(Filtro);

                return(View(ListProposal));
            }
        }
Beispiel #11
0
        public bool DoVote(VotesModel vote)
        {
            ProposalBussiness bussiness = new ProposalBussiness();

            return(bussiness.DoVote(vote));
        }
Beispiel #12
0
        public List <OptionModel> ConsultPartialResults(ProposalModel filter)
        {
            ProposalBussiness bussiness = new ProposalBussiness();

            return(bussiness.ConsultPartialResults(filter));
        }
Beispiel #13
0
        public List <ProposalModel> SearchProposalByUser(ProposalFilter filter)
        {
            ProposalBussiness bussiness = new ProposalBussiness();

            return(bussiness.SearchProposalByUser(filter));
        }
Beispiel #14
0
        public ActionResult Registrar(ProposalModel Data)
        {
            if (Data.QuestionTypeText == 0)
            {
                Data.QuestionTypeText = 1;
            }

            Data.QuestionType = (EnumQuestionType)Data.QuestionTypeText;

            ViewBag.Cantidad = 10;

            if (ModelState.IsValid)
            {
                ProposalBussiness ProposalLogic = new ProposalBussiness();
                UserModel         user          = (UserModel)Session["User"];

                if (Data.SelectedOptions.Count > 0)
                {
                    List <OptionModel> lst = new List <OptionModel>();
                    foreach (var item in Data.SelectedOptions[0].Split(','))
                    {
                        lst.Add(new OptionModel()
                        {
                            Description = item
                        });
                    }
                    Data.Options = lst;
                }


                Data.UserCreator = user.Email;

                if (Data.InitialDate >= Data.FinalDate)
                {
                    ViewBag.Error = "La fecha de inicio no puede ser mayor a la fecha final";
                }
                else
                {
                    if (Data.MinimumQuantitySelected <= Data.MaximumQuantitySelected)
                    {
                        if (Data.InitialDate < DateTime.Now.Date)
                        {
                            ViewBag.Error = "La fecha de inicio no puede ser antes del dia de hoy.";
                        }
                        else
                        {
                            if (Data.QuestionType != EnumQuestionType.Referendum)
                            {
                                if (Data.Options.Count < 2)
                                {
                                    ViewBag.Error = "Debe ingresar al menos dos opciones";
                                }
                                else
                                {
                                    if (ProposalLogic.InsertProposal(Data))
                                    {
                                        return(RedirectToAction("ProposalList", "Proposal"));
                                    }
                                    else
                                    {
                                        return(View("error"));
                                    }
                                }
                            }
                            else
                            {
                                if (ProposalLogic.InsertProposal(Data))
                                {
                                    return(RedirectToAction("ProposalList", "Proposal"));
                                }
                                else
                                {
                                    return(View("error"));
                                }
                            }
                        }
                    }
                    else
                    {
                        ViewBag.Error = "La cantidad minina, debe ser menor o igual a la cantidad maxima";
                    }
                }
            }
            else
            {
                return(View("NewProposal", Data));
            }
            return(View("NewProposal", Data));
        }