// GET: Client/AddClient
        public ActionResult AddClient()
        {
            if (Session["Usuario"] == null)
            {
                return RedirectToAction("Login", "User");
            }

            var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces;
            var ObjAcces = ObjAccesUser.Where(p => p.Action == "ListClient").First();
            if (ObjAcces != null)
            {
                if (ObjAcces.Create == false)
                {
                    return RedirectToAction("Index", "Home");
                }
            }


            MPerson objPersonClient = new MPerson();
            objPersonClient.Birthday = DateTime.Now.Date;
            objPersonClient.listPersonContact = new List<MPersonContact>();

            if (TempData["Success"] != null)
            {
                ViewBag.SuccessSave = TempData["Success"];
            }

            return View(objPersonClient);
        }
Пример #2
0
        public Person Save(MPerson person)
        {
            var institutionId = 0;

            if (!string.IsNullOrEmpty(person.Institution?.Name))
            {
                institutionId = _uInstitution.GetExact(person.Institution.Name)?.Id ?? 0;
                if (institutionId == 0)
                {
                    institutionId = _bInstitution.Save(person.Institution.Name).Id;
                }
            }
            var cPerson = new Person
            {
                Id        = person.Id,
                Name      = person.Name,
                Cpf       = person.Cpf.RCpf(),
                Email     = person.Email,
                BirthDate = person.BirthDate,
                Sex       = person.Sex,
                Password  = person.Password.Sha256Hash(),
                Profile   = person.Profile
            };

            if (institutionId != 0)
            {
                cPerson.InstitutionId = institutionId;
            }

            Save(cPerson);
            _context.SaveChanges();
            return(cPerson);
        }
Пример #3
0
        public void TestSaveConsigoCadastrarUmProfessorComInstituicaoJaExistente()
        {
            var institution = new Institution
            {
                Name = "UFLA"
            };

            _context.Institution.Add(institution);
            _context.SaveChanges();

            var mPerson = new MPerson
            {
                BirthDate   = DateTime.Now,
                Institution = new MInstitution
                {
                    Name = "UFLA"
                },
                Cpf      = "37551053654",
                Email    = "*****@*****.**",
                Name     = "Nome professor",
                Password = "******",
                Profile  = (int)EProfile.Teacher,
                Sex      = (int)ESex.Male
            };


            var res = _controller.Save(mPerson) as ObjectResult;

            Assert.NotNull(res);
            Assert.Equal((int)HttpStatusCode.OK, res.StatusCode);
            Assert.Equal("Cadastro realizado com sucesso!", ((MResponseContent)res.Value).message);
        }
Пример #4
0
        public ObservableCollection <MStunden> LoadStunden(MPerson value)
        {
            ObservableCollection <MStunden> result = new ObservableCollection <MStunden>();

            _XDoc = new XmlDocument();
            FileStream Stream = new FileStream(_FilePath, FileMode.Open);

            _XDoc.Load(Stream);
            XmlNodeList list = _XDoc.GetElementsByTagName(_SubName);

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement cl = (XmlElement)_XDoc.GetElementsByTagName(_SubName)[i];
                if (cl.GetAttribute("Id").Equals(value.Id))
                {
                    XmlNodeList l = cl.ChildNodes;
                    for (int j = 0; j < l.Count; j++)
                    {
                        XmlElement ca = (XmlElement)cl.GetElementsByTagName(_SubStunden)[i];
                        result.Add(new MStunden()
                        {
                            Id    = ca.GetAttribute("Id"),
                            Start = ca.GetAttribute("Start"),
                            Ende  = ca.GetAttribute("Ende"),
                            Pause = ca.GetAttribute("Pause")
                        });
                    }
                }
            }
            Stream.Close();
            return(result);
        }
Пример #5
0
 private static void AssertPerson(MPerson expected, MPerson actual)
 {
     Assert.AreEqual(expected.ID, actual.ID);
     Assert.AreEqual(expected.Gender, actual.Gender);
     Assert.AreEqual(expected.FirstName, actual.FirstName);
     Assert.AreEqual(expected.LastName, actual.LastName);
     Assert.AreEqual(expected.MiddleName, actual.MiddleName);
 }
Пример #6
0
 public void LoadStunden(MPerson value = null)
 {
     if (value != null)
     {
         foreach (MStunden std in value.Stunden)
         {
             ValueStunden.Add(std);
         }
     }
 }
Пример #7
0
        public void Add(MPerson value)
        {
            _XDoc   = new XmlDocument();
            _Stream = new FileStream(_FilePath, FileMode.Open);
            _XDoc.Load(_Stream);
            XmlElement cl = _XDoc.CreateElement(_SubName);

            cl.SetAttribute("Id", value.Id);
            cl.SetAttribute("VName", Crypt.EncryptString(value.VName, value.Id));
            cl.SetAttribute("NName", Crypt.EncryptString(value.NName, value.Id));
            cl.SetAttribute("Mid", Crypt.EncryptString(value.Mid, value.Id));
            cl.SetAttribute("TaughtNr", value.TaughtNr);
            _XDoc.DocumentElement.AppendChild(cl);
            _Stream.Close();
            _XDoc.Save(_FilePath);
        }
Пример #8
0
 /// <summary>
 /// 测试修改
 /// </summary>
 public static void UpdatePerson()
 {
     try
     {
         MPerson model = new MPerson();
         model.PersonName = "张三";
         model.PersonHome = "上海";
         BPerson bll    = new BPerson();
         int     result = bll.UpdatePerson(model);
         Console.WriteLine("结果:" + result);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
        // GET: Employee/EditEmployee/5
        public ActionResult EditEmployee(int?id)
        {
            if (Session["Usuario"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces;
            var ObjAcces     = ObjAccesUser.Where(p => p.Action == "ListEmployee").First();

            if (ObjAcces != null)
            {
                if (ObjAcces.Edit == false)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }

            //Aqui se trae el modelo enviado por POST desde la Lista, para que no se vea en la Url
            if (TempData["DataPersonEmployee"] != null)
            {
                var objTempData = Newtonsoft.Json.JsonConvert.DeserializeObject <MPerson>((string)TempData["DataPersonEmployee"]);
                if (objTempData != null && objTempData.IdPerson > 0)
                {
                    id = objTempData.IdPerson;
                }
                else
                {
                    return(RedirectToAction("ListEmployee", "Employee"));
                }
            }
            if (id == null)
            {
                return(RedirectToAction("ListEmployee", "Employee"));
            }
            //-----------------------------------------------------

            MPerson objPersonEmployee = new MPerson();

            objPersonEmployee = PersonController.fnListPerson(id, 2).First(); //2-empleado

            if (TempData["Success"] != null)
            {
                ViewBag.SuccessSave = TempData["Success"];
            }

            return(View(objPersonEmployee));
        }
        public ActionResult EditClient(MPerson objPersonClient)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //valores por defecto
                    objPersonClient.IdPersonType = 1; //tipo cliente

                    string mensaje = "";
                    int resultDb = PersonController.fnGNTranPerson(objPersonClient, "U", ref mensaje);

                    if (resultDb != 0)
                    {
                        TempData["Success"] = mensaje;

                        //Para evitar que se vea el id en la Url------------
                        MPerson objMPerson = new MPerson();
                        objMPerson.IdPerson = objPersonClient.IdPerson;

                        var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(objMPerson);
                        TempData["DataPersonClient"] = jsonString;
                        return RedirectToAction("EditClient");
                        //---------------------------------------------------

                        //return RedirectToAction("EditClient", new { id = objPersonClient.IdPerson });
                    }
                    else
                    {
                        ViewBag.ErrorSave = mensaje;
                        return View(objPersonClient);
                    }
                }
                else
                {
                    ViewBag.ErrorSave = "Error al grabar, Por favor verifique los datos ingresados.";
                    return View(objPersonClient);
                }

            }
            catch (Exception ex)
            {
                ViewBag.ErrorSave = "Error al grabar datos del cliente: " + ex.Message;
                return View(objPersonClient);
            }

        }
Пример #11
0
        public void Delete(MPerson value)
        {
            _XDoc   = new XmlDocument();
            _Stream = new FileStream(_FilePath, FileMode.Open);
            _XDoc.Load(_Stream);
            XmlNodeList list = _XDoc.GetElementsByTagName(_SubName);

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement cl = (XmlElement)_XDoc.GetElementsByTagName(_SubName)[i];
                if (value.Id.Equals(cl.GetAttribute("Id")))
                {
                    _XDoc.DocumentElement.RemoveChild(cl);
                    break;
                }
            }
            _Stream.Close();
            _XDoc.Save(_FilePath);
        }
Пример #12
0
        public void TestSaveConsigoCadastrarUmProfessorSemInstituicao()
        {
            var mPerson = new MPerson
            {
                BirthDate = DateTime.Now,
                Cpf       = "43754264206",
                Email     = "*****@*****.**",
                Name      = "Nome professor",
                Password  = "******",
                Profile   = (int)EProfile.Teacher,
                Sex       = (int)ESex.Male
            };


            var res = _controller.Save(mPerson) as ObjectResult;

            Assert.NotNull(res);
            Assert.Equal((int)HttpStatusCode.OK, res.StatusCode);
            Assert.Equal("Cadastro realizado com sucesso!", ((MResponseContent)res.Value).message);
        }
        public ActionResult ListClient()
        {
            if (Session["Usuario"] == null)
            {
                return RedirectToAction("Login", "User");
            }

            var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces;
            var ObjAcces = ObjAccesUser.Where(p => p.Action == "ListClient").First();
            if(ObjAcces!=null)
            {
                if(ObjAcces.Visible ==false)
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            MPerson objMPerson = new MPerson();
            return View(objMPerson);
        }
        public ActionResult ListClient(string submit, MPerson objMPerson)
        {
            if (objMPerson == null || objMPerson.IdPerson == 0)
            {
                return View();
            }

            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(objMPerson);
            TempData["DataPersonClient"] = jsonString;

            switch (submit)
            {
                case "searchRow":
                    return RedirectToAction("DetailClient", "Client");
                case "editRow":
                    return RedirectToAction("EditClient", "Client");
                default:
                    return View();
            }

        }
Пример #15
0
        public void TestSaveNaoConsigoCadastrarUmaPessoaComEmailExistente()
        {
            var mPerson = new MPerson
            {
                BirthDate   = DateTime.Now,
                Institution = null,
                Cpf         = "02820214428",
                Email       = "*****@*****.**",
                Name        = "Nome professor",
                Password    = "******",
                Profile     = (int)EProfile.Teacher,
                Sex         = (int)ESex.Male
            };


            var res = _controller.Save(mPerson) as ObjectResult;

            Assert.NotNull(res);
            Assert.Equal((int)HttpStatusCode.BadRequest, res.StatusCode);
            Assert.Equal("Campo(s) inválido(s)!", ((MResponseContent)res.Value).message);
        }
Пример #16
0
        public void TestSaveNaoConsigoCadastrarUmaPessoaComSenhaInvalida()
        {
            var mPerson = new MPerson
            {
                BirthDate   = DateTime.Now,
                Institution = null,
                Cpf         = "52660410216",
                Email       = "*****@*****.**",
                Name        = "Nome professor",
                Password    = "******",
                Profile     = (int)EProfile.Teacher,
                Sex         = (int)ESex.Male
            };


            var res = _controller.Save(mPerson) as ObjectResult;

            Assert.NotNull(res);
            Assert.Equal((int)HttpStatusCode.BadRequest, res.StatusCode);
            Assert.Equal("Campo(s) inválido(s)!", ((MResponseContent)res.Value).message);
        }
        // GET: Client/DetailClient/5
        public ActionResult DetailClient(int? id)
        {
            if (Session["Usuario"] == null)
            {
                return RedirectToAction("Login", "User");
            }

            var ObjAccesUser = ((MSerUser)Session["Usuario"]).UserAcces;
            var ObjAcces = ObjAccesUser.Where(p => p.Action == "ListClient").First();
            if (ObjAcces != null)
            {
                if (ObjAcces.Search == false)
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            //Aqui se trae el modelo enviado por POST desde la Lista, para que no se vea en la Url
            if (TempData["DataPersonClient"] != null)
            {
                var objTempData = Newtonsoft.Json.JsonConvert.DeserializeObject<MPerson>((string)TempData["DataPersonClient"]);
                if (objTempData != null && objTempData.IdPerson > 0)
                {
                    id = objTempData.IdPerson;
                }
                else
                {
                    return RedirectToAction("ListClient", "Client");
                }
            }
            if (id == null) 
            {
                return RedirectToAction("ListClient", "Client");
            }
            //-----------------------------------------------------

            MPerson objPersonClient = new MPerson();
            objPersonClient = PersonController.fnListPerson(id, 1).First(); //1-cliente
            return View(objPersonClient);
        }
Пример #18
0
 /// <summary>
 /// 测试添加人员列表
 /// </summary>
 public static void AddPersonList()
 {
     try
     {
         BPerson bll   = new BPerson();
         MPerson model = new MPerson();
         model.PersonName = "艾玛";
         model.PersonHome = "美国";
         List <MPerson> list = new List <MPerson>();
         list.Add(model);
         model            = new MPerson();
         model.PersonName = "汤姆";
         model.PersonHome = "美国";
         list.Add(model);
         bool result = bll.AddPersonList(list);
         Console.WriteLine(result);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Пример #19
0
        public void Update(MPerson value)
        {
            _XDoc   = new XmlDocument();
            _Stream = new FileStream(_FilePath, FileMode.Open);
            _XDoc.Load(_Stream);
            XmlNodeList list = _XDoc.GetElementsByTagName(_SubName);

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement cl = (XmlElement)_XDoc.GetElementsByTagName(_SubName)[i];
                if (value.Id.Equals(cl.GetAttribute("Id")))
                {
                    cl.SetAttribute("VName", Crypt.EncryptString(value.VName, value.Id));
                    cl.SetAttribute("NName", Crypt.EncryptString(value.NName, value.Id));
                    cl.SetAttribute("Mid", Crypt.EncryptString(value.Mid, value.Id));
                    cl.SetAttribute("TaughtNr", value.TaughtNr);
                    break;
                }
            }
            _Stream.Close();
            _XDoc.Save(_FilePath);
        }
Пример #20
0
        public IActionResult Save([FromBody] MPerson person)
        {
            if (person == null)
            {
                return(BadRequest(ResponseContent.Create(null, HttpStatusCode.BadRequest, "Existe(m) campo(s) obrigatório(s) vazio(s)!")));
            }

            var errors = new List <MModelError>();

            person.ListErrors(_uPerson, ref errors);

            if (errors.Any())
            {
                return(BadRequest(ResponseContent.Create(errors, HttpStatusCode.BadRequest, "Campo(s) inválido(s)!")));
            }

            var newPerson = _bPerson.Save(person);

            _bHistory.SaveHistory(newPerson.Id, "Usuário registrou no sistema");

            return(Ok(ResponseContent.Create(null, HttpStatusCode.Created, "Cadastro realizado com sucesso!")));
        }
Пример #21
0
        public IActionResult Me()
        {
            if (!HttpContext.Session.IsAuth())
            {
                return(StatusCode((int)HttpStatusCode.Unauthorized, ResponseContent.Create(null, HttpStatusCode.Unauthorized, "Não autorizado!")));
            }
            var person  = _uPerson.GetById(HttpContext.Session.GetSessionPersonId());
            var mPerson = new MPerson
            {
                Name        = person.Name,
                Cpf         = person.Cpf,
                Email       = person.Email,
                Institution = new MInstitution
                {
                    Id   = person.Institution?.Id ?? 0,
                    Name = person.Institution?.Name
                },
                Profile = person.Profile,
                Photo   = person.PhotoPath
            };

            return(Ok(ResponseContent.Create(mPerson, HttpStatusCode.OK, null)));
        }
Пример #22
0
        public ObservableCollection <MPerson> Load()
        {
            ObservableCollection <MPerson> result = new ObservableCollection <MPerson>();

            _XDoc   = new XmlDocument();
            _Stream = new FileStream(_FilePath, FileMode.Open);
            _XDoc.Load(_Stream);
            XmlNodeList list = _XDoc.GetElementsByTagName(_SubName);

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement cl = (XmlElement)_XDoc.GetElementsByTagName(_SubName)[i];
                MPerson    r  = new MPerson()
                {
                    Id       = cl.GetAttribute("Id"),
                    VName    = Crypt.DecryptString(cl.GetAttribute("VName"), cl.GetAttribute("Id")),
                    NName    = Crypt.DecryptString(cl.GetAttribute("NName"), cl.GetAttribute("Id")),
                    Mid      = Crypt.DecryptString(cl.GetAttribute("Mid"), cl.GetAttribute("Id")),
                    TaughtNr = cl.GetAttribute("TaughtNr"),
                    Stunden  = new ObservableCollection <MStunden>()
                };
                for (int j = 0; j < cl.ChildNodes.Count; j++)
                {
                    XmlElement ca = (XmlElement)cl.ChildNodes[j];
                    r.Stunden.Add(new MStunden()
                    {
                        Id    = ca.GetAttribute("Id"),
                        Start = ca.GetAttribute("Start"),
                        Ende  = ca.GetAttribute("Ende"),
                        Pause = ca.GetAttribute("Pause")
                    });
                }
                result.Add(r);
            }
            _Stream.Close();
            return(result);
        }
        public ActionResult AddClient(MPerson objPersonClient)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //valores por defecto
                    objPersonClient.Status = true; //activo
                    objPersonClient.IdPersonType = 1; //tipo cliente

                    string mensaje = "";
                    int resultDb = PersonController.fnGNTranPerson(objPersonClient, "I", ref mensaje);

                    if (resultDb != 0)
                    {
                        TempData["Success"] = mensaje;
                        return RedirectToAction("AddClient");
                    }
                    else
                    {
                        ViewBag.ErrorSave = mensaje;
                        return View(objPersonClient);
                    }
                }
                else
                {
                    ViewBag.ErrorSave = "Error al grabar, Por favor verifique los datos ingresados.";
                    return View(objPersonClient);
                }

            }
            catch (Exception ex)
            {
                ViewBag.ErrorSave = "Error al grabar datos del cliente: " + ex.Message;
                return View(objPersonClient);
            }
        }
Пример #24
0
        public void AddStunden(MStunden stunden, MPerson person)
        {
            _XDoc   = new XmlDocument();
            _Stream = new FileStream(_FilePath, FileMode.Open);
            _XDoc.Load(_Stream);
            XmlNodeList list = _XDoc.GetElementsByTagName(_SubName);

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement cl = (XmlElement)_XDoc.GetElementsByTagName(_SubName)[i];
                if (person.Id.Equals(cl.GetAttribute("Id")))
                {
                    XmlElement ca = _XDoc.CreateElement(_SubStunden);
                    ca.SetAttribute("Id", stunden.Id);
                    ca.SetAttribute("Start", stunden.Start);
                    ca.SetAttribute("Ende", stunden.Ende);
                    ca.SetAttribute("Pause", stunden.Pause);
                    cl.AppendChild(ca);
                    break;
                }
            }
            _Stream.Close();
            _XDoc.Save(_FilePath);
        }
Пример #25
0
 public DPersonAddEdit(MPerson person = null)
 {
     InitializeComponent();
     this.WindowStyle = WindowStyle.None;
     if (person == null)
     {
         Value = new MPerson()
         {
             Id       = Guid.NewGuid().ToString(),
             VName    = "Max",
             NName    = "Mustermann",
             Mid      = "000",
             TaughtNr = ""
         };
     }
     else
     {
         Value = person;
     }
     VName.Text    = Value.VName;
     NName.Text    = Value.NName;
     Mid.Text      = Value.Mid;
     TaughtNr.Text = Value.TaughtNr;
 }
        public static int fnGNTranPerson(MPerson objPerson, string TransactionType, ref string Mensaje)
        {
            try
            {
                TextInfo ti = CultureInfo.CurrentCulture.TextInfo; //para capitalizar textos

                MMEnterprisesEntities db = new MMEnterprisesEntities();

                int IdPerson;
                int IdContact;
                int SqlResultPerson;
                int SqlResult;

                SqlParameter paramOutIdPerson = new SqlParameter();
                paramOutIdPerson.ParameterName = "@IdPerson";
                paramOutIdPerson.SqlDbType     = System.Data.SqlDbType.Int;
                paramOutIdPerson.Direction     = System.Data.ParameterDirection.InputOutput;
                paramOutIdPerson.Value         = objPerson.IdPerson;

                SqlParameter paramIdContactType = new SqlParameter();
                paramIdContactType.ParameterName = "@IdContactType";
                paramIdContactType.SqlDbType     = System.Data.SqlDbType.Int;
                paramIdContactType.Direction     = System.Data.ParameterDirection.Input;
                paramIdContactType.IsNullable    = true;
                if (objPerson.IdContactType != null)
                {
                    paramIdContactType.Value = objPerson.IdContactType;
                }
                else
                {
                    paramIdContactType.Value = DBNull.Value;
                }

                SqlParameter paramIdPosition = new SqlParameter();
                paramIdPosition.ParameterName = "@IdPosition";
                paramIdPosition.SqlDbType     = System.Data.SqlDbType.Int;
                paramIdPosition.Direction     = System.Data.ParameterDirection.Input;
                paramIdPosition.IsNullable    = true;
                if (objPerson.IdPosition != null)
                {
                    paramIdPosition.Value = objPerson.IdPosition;
                }
                else
                {
                    paramIdPosition.Value = DBNull.Value;
                }

                SqlParameter paramIdDepartment = new SqlParameter();
                paramIdDepartment.ParameterName = "@IdDepartment";
                paramIdDepartment.SqlDbType     = System.Data.SqlDbType.Int;
                paramIdDepartment.Direction     = System.Data.ParameterDirection.Input;
                paramIdDepartment.IsNullable    = true;
                if (objPerson.IdDepartment != null)
                {
                    paramIdDepartment.Value = objPerson.IdDepartment;
                }
                else
                {
                    paramIdDepartment.Value = DBNull.Value;
                }

                MUser objUser = new MUser();

                SqlResultPerson = db.Database.ExecuteSqlCommand("GNTranPerson @TransactionType, @IdPerson OUT, @IdPersonType " +
                                                                ", @IdIdentificationType, @strNumIdentification, @strName, @strLastName, @dttBirthday " +
                                                                ", @strAddress, @strEmail, @IdContactType, @IdPosition, @btClientPermission, @btStatus, @IdDepartment ",
                                                                new SqlParameter[] {
                    new SqlParameter("@TransactionType", TransactionType),
                    paramOutIdPerson,
                    new SqlParameter("@IdPersonType", objPerson.IdPersonType),
                    new SqlParameter("@IdIdentificationType", objPerson.IdIdentificationType),
                    new SqlParameter("@strNumIdentification", objUser.Encriptar(objPerson.NumIdentification)),
                    new SqlParameter("@strName", ti.ToTitleCase(objPerson.Name)),
                    new SqlParameter("@strLastName", ti.ToTitleCase(objPerson.LastName)),
                    new SqlParameter("@dttBirthday", objPerson.Birthday),
                    new SqlParameter("@strAddress", objUser.Encriptar(objPerson.Address)),
                    new SqlParameter("@strEmail", objPerson.Email),
                    paramIdContactType,
                    paramIdPosition,
                    new SqlParameter("@btClientPermission", objPerson.ClientPermission),
                    new SqlParameter("@btStatus", objPerson.Status),
                    paramIdDepartment
                }
                                                                );

                IdPerson = Int32.Parse(paramOutIdPerson.Value.ToString());

                if (IdPerson != 0)
                {
                    if (objPerson.listPersonContact != null)
                    {
                        if (objPerson.listPersonContact.Count() > 0)
                        {
                            //si va a actualizar, se eliminan los telefonos de contacto para volver a insertar
                            if (TransactionType == "U")
                            {
                                SqlParameter paramOutIdContact = new SqlParameter("@IdContact", System.Data.SqlDbType.Int);
                                paramOutIdContact.Direction = System.Data.ParameterDirection.Output;

                                SqlResult = db.Database.ExecuteSqlCommand("GNTranPersonContact @TransactionType, @IdContact OUT, @IdPerson " +
                                                                          ", @IdPhoneNumberType, @strIdIsoCountry, @strPhoneNumber, @btStatus ",
                                                                          new SqlParameter[] {
                                    new SqlParameter("@TransactionType", TransactionType),
                                    paramOutIdContact,
                                    new SqlParameter("@IdPerson", IdPerson),
                                    new SqlParameter("@IdPhoneNumberType", DBNull.Value),
                                    new SqlParameter("@strIdIsoCountry", DBNull.Value),
                                    new SqlParameter("@strPhoneNumber", DBNull.Value),
                                    new SqlParameter("@btStatus", DBNull.Value)
                                }
                                                                          );
                            }

                            //Inserta los telefonos de contacto
                            foreach (var item in objPerson.listPersonContact)
                            {
                                SqlParameter paramOutIdContact = new SqlParameter("@IdContact", System.Data.SqlDbType.Int);
                                paramOutIdContact.Direction = System.Data.ParameterDirection.Output;

                                SqlResult = db.Database.ExecuteSqlCommand("GNTranPersonContact @TransactionType, @IdContact OUT, @IdPerson " +
                                                                          ", @IdPhoneNumberType, @strIdIsoCountry, @strPhoneNumber, @btStatus ",
                                                                          new SqlParameter[] {
                                    new SqlParameter("@TransactionType", "I"),
                                    paramOutIdContact,
                                    new SqlParameter("@IdPerson", IdPerson),
                                    new SqlParameter("@IdPhoneNumberType", item.IdPhoneNumberType),
                                    new SqlParameter("@strIdIsoCountry", item.IdIsoCountry),
                                    new SqlParameter("@strPhoneNumber", objUser.Encriptar(item.PhoneNumber)),
                                    new SqlParameter("@btStatus", true)
                                }
                                                                          );
                                IdContact = Int32.Parse(paramOutIdContact.Value.ToString());
                            }
                        }
                    }

                    //Mensaje = "Datos grabados exitosamente para el Código de empleado: (" + IdPerson + ").";
                    Mensaje = "Datos grabados exitosamente.";
                }
                else
                {
                    Mensaje = "No se pudo realizar la transaccion, intente nuevamente.";
                }

                return(SqlResultPerson);
            }
            catch (SqlException ex)
            {
                Mensaje = "Error al grabar datos: " + ex.Message;
                return(0);
            }
        }