Ejemplo n.º 1
0
        public IActionResult Get()
        {
            var user       = ObtenerIDUser();
            var objCompany = context.Company.FirstOrDefault(x => x.Rut == (context.UsersCompany.FirstOrDefault(x => x.IdUser == user).idCompany));
            var mCompany   = new ModelIniCommpany();

            mCompany.Name  = objCompany.Name;
            mCompany.Rut   = objCompany.Rut;
            mCompany.email = objCompany.email;
            mCompany.Image = objCompany.Image;

            return(Ok(mCompany));
        }
Ejemplo n.º 2
0
        public IActionResult Post([FromBody] ModelIniCommpany company)
        {
            if (ModelState.IsValid)
            {
                var userid = ObtenerIDUser();
                try
                {
                    var objCompany = new Company();
                    objCompany.Name  = company.Name;
                    objCompany.email = company.email;
                    objCompany.Rut   = company.Rut;
                    context.Company.Add(objCompany);
                    context.SaveChanges();
                    return(Ok());
                }
                catch (IOException e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(BadRequest(ModelState));
        }