public override void ProcessRequest(HttpContext context) { try { var periodIdString = context.Request.Form["Id"]; long periodId = 0; long.TryParse(Commons.SecurityUtils.descriptografar(periodIdString), out periodId); if (periodId > 0) { using (Lib.Repositories.PeriodRepository repository = new Lib.Repositories.PeriodRepository(this.ActiveUser)) { var period = repository.getInstanceById(periodId); if (period != null) { period.Published = true; period.Open = false; repository.save(period); } else { throw new Exception(Resources.Message.period_not_found); } } } else { throw new Exception(Resources.Message.period_id_not_found); } context.Response.ContentType = "text/plain"; context.Response.Write("Ok"); } catch (Exception ex) { Lib.Log.ErrorLog.saveError("Web.Handler.ResponseForm.Action.ProcessRequest", ex); context.Response.StatusCode = 500; context.Response.Write(Resources.Message.couldnt_process_request); } }
private void loadForm() { using (Lib.Repositories.PeriodRepository rep = new Lib.Repositories.PeriodRepository(this.ActiveUser)) { hdnPeriodId.Value = Page.Request.QueryString["id"]; long periodId = Convert.ToInt64(Commons.SecurityUtils.descriptografar(hdnPeriodId.Value)); var period = rep.getInstanceById(periodId); txtName.Text = period.Name; txtFinalDate.Text = period.FinalDate.ToString("dd/MM/yyyy"); txtInitialDate.Text = period.InitialDate.ToString("dd/MM/yyyy"); txtConvocationInitialDate.Text = period.ConvocationInitialDate.ToString("dd/MM/yyyy"); txtConvocationFinalDate.Text = period.ConvocationFinalDate.ToString("dd/MM/yyyy"); txtName.Enabled = false; //txtInitialDate.Enabled = false; chkAberto.Checked = period.Open; } }