예제 #1
0
        public bool UpdateProposal(ProposalModel proposal)
        {
            try
            {
                if (proposal == null)
                {
                    return(false);
                }

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(API_Dictionary.Base);

                // Add an Accept header for JSON format.
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                DateTime            dateCalcule = DateTime.Today;
                HttpResponseMessage response    = client.GetAsync(string.Format(API_Dictionary.UpdateProposal,
                                                                                proposal.ContracEthereumProposal,
                                                                                proposal.ProposalName,
                                                                                DiffDateTimeInMinutes(dateCalcule, proposal.InitialDate),
                                                                                DiffDateTimeInMinutes(dateCalcule, proposal.FinalDate),
                                                                                (int)proposal.SecurityType,
                                                                                proposal.AdvancedSearch,
                                                                                proposal.MinimumQuantitySelected,
                                                                                proposal.MaximumQuantitySelected
                                                                                )).Result;
                if (response.IsSuccessStatusCode)
                {
                    proposal.ContracEthereumProposal = response.Content.ReadAsAsync <string>().Result;

                    bool isUpdateSuccess;
                    using (ProposalDataAccess proposalDataAccess = new ProposalDataAccess())
                    {
                        isUpdateSuccess = proposalDataAccess.UpdateProposal(proposal);
                    }
                    return(isUpdateSuccess);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #2
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"));
            }
        }