Пример #1
0
        public IActionResult AgregarComunicacion(ContactCommunicationModel model)
        {
            var data = CopyPropierties.Convert <ContactCommunicationModel, ContactCommunication>(model);

            if (string.IsNullOrWhiteSpace(model.Communication.CommunicationPhoneNumber1) && string.IsNullOrWhiteSpace(model.Communication.CommunicationPhoneNumber2))
            {
                EnviarMensaje.Enviar(TempData, "red", "Al menos un número de contacto es requerido");
                return(RedirectToAction("AgregarComunicacion", new { id = model.TeacherId }));
            }

            if (string.IsNullOrWhiteSpace(model.Communication.CommunicationEmail))
            {
                EnviarMensaje.Enviar(TempData, "red", "El email es requerido ");
                return(RedirectToAction("AgregarComunicacion", new { id = model.TeacherId }));
            }

            try
            {
                _contactCommunication.Save(data);
            }
            catch (Exception e)
            {
                return(RedirectToAction("AgregarComunicacion", new { id = model.TeacherId }));
            }

            return(RedirectToAction("AgregarComunicacion", new { id = model.TeacherId }));
        }
Пример #2
0
        public IActionResult AgregarComunicacion(int id)
        {
            var model       = new ContactCommunicationModel();
            var contactId   = _teacher.GetContactId(id);
            var teacherById = _teacher.GetById(id);

            model.ContactId         = contactId;
            model.TeacherId         = teacherById.TeacherId;
            model.TeacherFullName   = teacherById.Contact.ContactName + " " + teacherById.Contact.ContactLastname;
            model.CommunicationList = _contactCommunication.GetAllByContactId(contactId).ToList();

            return(View(model));
        }