public frmAnketeEdit(int id)
        {
            InitializeComponent();
            this.AutoValidate = AutoValidate.Disable;

            _id = id;
            _a  = null;
        }
Ejemplo n.º 2
0
        private List <ValidationResult> Validate(AnketaModel ankm)
        {
            var results = new List <ValidationResult>();
            var vc      = new ValidationContext(ankm, null, null);

            Validator.TryValidateObject(ankm, vc, results, true);
            return(results);
        }
Ejemplo n.º 3
0
        public frmAnketeDetails(int id)
        {
            InitializeComponent();

            _id = id;
            _a  = null;

            InitializeChart();
        }
Ejemplo n.º 4
0
        private void btnSnimi_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                var a = new AnketaModel();
                a.Naslov     = txtNaslov.Text;
                a.Datum      = DateTime.Now;
                a.KorisnikId = Global.PrijavljeniKorisnik.Id;

                var odgovori = new List <AnketaOdgovorModel>();
                if (cbOdgovor1.Checked)
                {
                    odgovori.Add(new AnketaOdgovorModel {
                        Odgovor = txtOdgovor1.Text, RedniBroj = 1
                    });
                }
                if (cbOdgovor2.Checked)
                {
                    odgovori.Add(new AnketaOdgovorModel {
                        Odgovor = txtOdgovor2.Text, RedniBroj = 2
                    });
                }
                if (cbOdgovor3.Checked)
                {
                    odgovori.Add(new AnketaOdgovorModel {
                        Odgovor = txtOdgovor3.Text, RedniBroj = 3
                    });
                }
                if (cbOdgovor4.Checked)
                {
                    odgovori.Add(new AnketaOdgovorModel {
                        Odgovor = txtOdgovor4.Text, RedniBroj = 4
                    });
                }
                if (cbOdgovor5.Checked)
                {
                    odgovori.Add(new AnketaOdgovorModel {
                        Odgovor = txtOdgovor5.Text, RedniBroj = 5
                    });
                }

                a.Odgovori = odgovori;

                HttpResponseMessage response = anketeService.PostResponse(a).Handle();
                if (response.IsSuccessStatusCode)
                {
                    MessageBox.Show(Messages.add_anketa_succ, Messages.msg_succ, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
        }
Ejemplo n.º 5
0
        private void frmAnketeDetails_Load(object sender, EventArgs e)
        {
            HttpResponseMessage response = anketeService.GetResponse(_id.ToString()).Handle();

            if (response.IsSuccessStatusCode)
            {
                _a = response.GetResponseResult <AnketaModel>();
                LoadPieChart();
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                _a = null;
            }
        }
Ejemplo n.º 6
0
        public ActionResult EditAnketa(int FileID, int ID)
        {
            // throw new ArgumentException("Специальная ошибка для теста");
            AnketaModel ankm = new AnketaModel()
            {
                FileId = FileID, Birthday = DateTime.Now
            };

            if (ID > 0)
            {
                // сопоставление
                ankm = Mapper.Map <AnketaModel>(_Facade.Keeper.GetAnketa(ID));
            }
            return(PartialView(ankm));
        }
Ejemplo n.º 7
0
        public T ConvertIt <T>(string line)
        {
            if (typeof(T).Name != "Anketa")
            {
                throw new Exception("Wrong type!");
            }

            var splited = line.Split(Splitby);

            if (splited.Length != 4)
            {
                throw new Exception("Not all fields filled!");
            }
            // Валидируем AnketaModel
            var ankm = new AnketaModel()
            {
                FIO      = splited[0],
                Birthday = DateTime.Parse(splited[1]),
                Email    = splited[2],
                Phone    = splited[3]
            };
            var results = Validate(ankm);

            if (results.Count > 0)
            {
                throw new Exception(results[0].MemberNames.ToList()[0] + " " + results[0].ErrorMessage);
            }
            // Возварщаем Anketa
            var ank = new Anketa()
            {
                FIO      = ankm.FIO,
                Birthday = ankm.Birthday,
                Email    = ankm.Email,
                Phone    = ankm.Phone
            };

            return((T)Convert.ChangeType(ank, typeof(T)));
        }
Ejemplo n.º 8
0
        }                                   // Empty constructor for unit testing purpose

        public AnketaViewModel(Anketa _anketa)
        {
            _AnketaModel = Mapper.Map <AnketaModel>(_anketa);
        }