예제 #1
0
 public ActionResult Create(ParentRegisterModel modelParent)
 {
     var parentModel = Mapper.Map<ParentRegisterModel, Parent>(modelParent);
     var myParent = _parentRepository.GenerateParentFromRegisterModel(parentModel);
     if (_parentRepository.ExistIdNumber(modelParent.IdNumber))
     {
         _viewMessageLogic.SetNewMessage("Dato Invalido", "Ya existe el numero de Identidad ya existe", ViewMessageType.ErrorMessage);
         return RedirectToAction("Index");
     }
     if (_parentRepository.ExistEmail(modelParent.Email))
     {
         _viewMessageLogic.SetNewMessage("Dato Invalido", "El Correo Electronico ya esta en uso", ViewMessageType.ErrorMessage);
         return RedirectToAction("Index");
     }
     var newUser = new User
     {
         DisplayName = myParent.FirstName,
         Email = modelParent.Email,
         Password = modelParent.Password,
         IsActive = true,
         Role = Roles.Padre
     };
     newUser = _userRepository.Create(newUser);
     myParent.MyUser = newUser;
      _parentRepository.Create(myParent);
     const string title = "Padre o Tutor Agregado";
     var content = "El Padre o Tutor " + myParent.FullName + " ha sido agregado exitosamente.";
     _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
     return RedirectToAction("Index");
 }
예제 #2
0
 public Parent GenerateParentFromRegisterModel(ParentRegisterModel parentRegisterModel)
 {
     return new Parent
     {
         FirstName = parentRegisterModel.FirstName,
         LastName = parentRegisterModel.LastName,
         FullName = (parentRegisterModel.FirstName + " " + parentRegisterModel.LastName).Trim(),
         IdNumber = parentRegisterModel.IdNumber,
         BirthDate = parentRegisterModel.BirthDate,
         Gender = Utilities.IsMasculino(parentRegisterModel.Gender),
         Nationality = parentRegisterModel.Nationality,
         State = parentRegisterModel.State,
         Country = parentRegisterModel.Country,
         City = parentRegisterModel.City,
         Address = parentRegisterModel.Address,
     };
 }
예제 #3
0
 public ActionResult Create()
 {
     var modelRegister = new ParentRegisterModel();
     return View(modelRegister);
 }