コード例 #1
0
 public static void AddAttender(Attender attender)
 {
     attender.Id = listaAsistentes.Count() + 1;
     listaAsistentes.Add(attender);
 }
コード例 #2
0
        public ActionResult Create(string Name, int? Age, string Comments, string Profesion, bool ReturnNextYear, int[] TalksIds)
        {
            try
            {
                var attender = new Attender();

                if (string.IsNullOrEmpty(Name))
                    ModelState.AddModelError("Name", "El nombre es un campo obligatorio.");
                else
                    attender.Name = Name;


                if (!Age.HasValue || Age.Value == 0)
                    ModelState.AddModelError("Age", "La edad es un campo obligatorio.");
                else
                    attender.Age = Age.Value;

                attender.Comments = Comments;
                attender.Profesion = Profesion;
                attender.ReturnNextYear = ReturnNextYear;
                attender.TalksIds = TalksIds;

                if (!ModelState.IsValid)
                {
                    ViewData["TalksList"] = GetTalksList(attender.TalksIds);
                    return View();
                }

                AttenderRepository.AddAttender(attender);

                return RedirectToAction("Index");
            }
            catch
            {
                ViewData["TalksList"] = GetTalksList();

                return View();
            }
        }
コード例 #3
0
        public ActionResult Edit(Attender attender)
        {
            try
            {
                if (string.IsNullOrEmpty(attender.Name))
                    ModelState.AddModelError("Name", "El nombre es un campo obligatorio.");

                if (attender.Age == 0)
                    ModelState.AddModelError("Age", "La edad es un campo obligatorio.");

                if (!ModelState.IsValid)
                {
                    ViewData["TalksList"] = GetTalksList(attender.TalksIds);

                    return View();
                }

                var currentAttender = AttenderRepository.GetAttender(attender.Id);

                currentAttender.Name = attender.Name;
                currentAttender.Age = attender.Age;
                currentAttender.Comments = attender.Comments;
                currentAttender.ReturnNextYear = attender.ReturnNextYear;
                currentAttender.TalksIds = attender.TalksIds;

                return RedirectToAction("Index");
            }
            catch
            {
                ViewData["TalksList"] = GetTalksList(attender.TalksIds);

                return View();
            }
        }
コード例 #4
0
 public static void AddAttender(Attender attender)
 {
     attender.Id = listaAsistentes.Count() + 1;
     listaAsistentes.Add(attender);
 }