コード例 #1
0
        public ActionResult Edit(StudentViewModel student)
        {
            if (!ModelState.IsValid)
            {
                return(View(student).WithError("Hubo un error en el modelo"));
            }
            _studentService.Update(student.GenericConvert <domain.Student>());

            return(RedirectToAction("Maintenance"));
        }
コード例 #2
0
        public ActionResult Create(StudentViewModel student)
        {
            if (!ModelState.IsValid)
            {
                return(View(student).WithError("Hubo un error en el modelo"));
            }
            if (_studentService.ValidateDocumentID(student.DocumentID))
            {
                return(View(student).WithError("Número de Cedula ingresado ya existe"));
            }
            if (_studentService.ValidateRegisterNumber(student.RegisterNumber))
            {
                return(View(student).WithError("Matrícula ingresada ya existe"));
            }

            var studentEntity = student.GenericConvert <domain.Student>();

            studentEntity.Status  = Status.Active;
            studentEntity.Created = DateTime.Now;
            _studentService.Add(studentEntity);

            return(RedirectToAction("Create").WithSuccess($"{student.FullName}, fue creado satisfactoriamente"));
        }