Example #1
0
        public Response AddPaciente([FromBody] PacienteViewModel model)
        {
            Response oR = new Response();

            try
            {
                Models.Paciente oPaciente = new Models.Paciente
                {
                    Nombre = model.Nombre,
                    NumeroDeSeguroSocial = model.NumeroDeSeguroSocial,
                    CodigoPostal         = model.CodigoPostal,
                    Telefono             = model.Telefono,
                    CedulaDoctor         = model.CedulaDoctor
                };
                db.Paciente.Add(oPaciente);
                db.SaveChanges();

                oR.Succes = 1;
            }
            catch (Exception ex) {
                oR.Succes  = 0;
                oR.Message = ex.Message;
            }
            return(oR);
        }
Example #2
0
        public MyResponse Add([FromBody] ServicioViewModel ServicioAgregar)
        {
            MyResponse Res = new MyResponse();

            try
            {
                if (ServicioAgregar != null)
                {
                    var resultado = db.clientes.FirstOrDefault(p => p.Id == ServicioAgregar.fk_Cliente.Id);


                    Models.Servicios oServicio = new Models.Servicios();
                    oServicio.valorxHora     = ServicioAgregar.valorxHora;
                    oServicio.nombreServicio = ServicioAgregar.nombreServicio;
                    oServicio.fk_Cliente     = resultado;

                    db.servicios.Add(oServicio);
                    db.SaveChanges();
                    Res.Success = 1;
                }
                else
                {
                    Res.Message = "Sericio Nulo";
                }
            }
            catch (Exception e)
            {
                Res.Success = 0;
                Res.Message = e.Message;
            }
            return(Res);
        }
        public MyResponse Add([FromBody] ServicioPaisViewModel ServicioPaisAgregar)
        {
            MyResponse Res = new MyResponse();

            try
            {
                if (ServicioPaisAgregar != null)
                {
                    var resultadopais     = db.paises.FirstOrDefault(p => p.Id == ServicioPaisAgregar.fk_IdPais.Id);
                    var resultadoservicio = db.servicios.FirstOrDefault(p => p.Id == ServicioPaisAgregar.fK_IdServicio.Id);

                    Models.Servicios_Pais oServicioPais = new Models.Servicios_Pais();
                    oServicioPais.fk_IdPais     = resultadopais;
                    oServicioPais.fK_IdServicio = resultadoservicio;

                    db.servicios_pais.Add(oServicioPais);
                    db.SaveChanges();
                    Res.Success = 1;
                }
                else
                {
                    Res.Message = "Sericio Nulo";
                }
            }
            catch (Exception e)
            {
                Res.Success = 0;
                Res.Message = e.Message;
            }
            return(Res);
        }
Example #4
0
        public MyResponse Add([FromBody] MessageViewModel model)
        {
            MyResponse oR = new MyResponse();

            //var result = db.User.Where(c => c.FirstName == "Cesar" & c.SurName == "Arcos").FirstOrDefault();

            try
            {
                Models.User oMessage = new Models.User();
                oMessage.FirstName      = model.FirstName;
                oMessage.SurName        = model.SurName;
                oMessage.Identification = model.Identification;
                oMessage.Password       = model.Password;
                oMessage.Email          = model.Email;
                db.User.Add(oMessage);
                db.SaveChanges();
                oR.Success = 1;
            }
            catch (Exception ex)
            {
                oR.Success = 0;
                oR.Message = ex.Message;
            }
            return(oR);
        }
        public MyResponse Add([FromBody] UsuarioViewModel model)
        {
            MyResponse oR = new MyResponse();

            try
            {
                Models.tbl_usuario oUsuario = new Models.tbl_usuario();
                oUsuario.usu_nombre   = model.usu_nombre;
                oUsuario.usu_apellido = model.usu_apellido;
                oUsuario.usu_email    = model.usu_email;
                oUsuario.usu_estado   = model.usu_estado;

                db.Usuario.Add(oUsuario);
                db.SaveChanges();

                oR.Success = 1;
            }
            catch (Exception ex)
            {
                oR.Success = 0;
                oR.Message = ex.Message;
            }

            return(oR);
        }
        public Response Create([FromBody] UserViewModel model)
        {
            Response response = new Response();

            try
            {
                Models.User newUser = new Models.User
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Email     = model.Email,
                    Username  = model.Username,
                    Password  = model.Password,
                    Rol       = Int32.Parse(model.Rol)
                };
                db.User.Add(newUser);
                db.SaveChanges();
                response.Success = 1;
            }
            catch (Exception ex)
            {
                response.Success = 0;
                response.Message = ex.Message;
            }

            return(response);
        }
Example #7
0
        public MyResponse Add([FromBody] ClienteViewModel ClienteIngresar)
        {
            MyResponse Res = new MyResponse();

            try
            {
                Models.Clientes oCliente = new Models.Clientes();
                oCliente.NIT    = ClienteIngresar.NIT;
                oCliente.nombre = ClienteIngresar.nombre;
                oCliente.correo = ClienteIngresar.correo;
                db.clientes.Add(oCliente);
                db.SaveChanges();
                Res.Success = 1;
            }
            catch (Exception e)
            {
                Res.Success = 0;
                Res.Message = e.Message;
            }
            return(Res);
        }
Example #8
0
        public ActionResult Getsginup(string Username, string email, string password)
        {
            var so = db.User.FirstOrDefault(a => a.UserAccount == Username);

            if (so == null)
            {
                G2_MVC_EF.Models.User user = new User();
                user.UserAccount = Username;
                user.Userphone   = email;
                user.UserPwd     = password;
                db.User.Add(user);
                int i = db.SaveChanges();
                if (i == 1)
                {
                    return(Redirect("/Index/Login"));
                }
            }
            else
            {
                return(Content("<script>alert('用户已被注册');window.location.href='/Index/sginup';</script>"));
            }
            return(Content("<script>alert('注册失败');</script>"));
        }
Example #9
0
        public Status Add([FromBody] MessageViewModel model)
        {
            Status oR = new Status();

            try
            {
                Models.Message oMessage = new Models.Message();
                oMessage.Name = model.Name;
                oMessage.Text = model.Text;
                db.Message.Add(oMessage);
                db.SaveChanges();
                oR.Succes = 1;
            }
            catch (Exception ex) {
                oR.Succes  = 0;
                oR.Message = ex.Message;
            }
            return(oR);
        }
Example #10
0
        public MyResponse Add([FromBody] MessageViewModel model)
        {
            MyResponse response = new MyResponse();

            try
            {
                Models.Message message = new Models.Message();
                message.Name           = model.Name;
                message.MessageContent = model.MessageContent;

                db.Message.Add(message);
                db.SaveChanges();

                response.Success = 1;
            }
            catch (Exception ex)
            {
                response.Success = 0;
                response.Message = "Ocurrio un error: " + ex.Message;
            }

            return(response);
        }