public IActionResult Update(string id, [FromBody] ProfileStudent _ProfileStudent)
        {
            var tEntity = context.ProfileStudent.FirstOrDefault(e => e.ProfileId.Equals(id));


            if (tEntity != null)
            {
                try
                {
                    tEntity.Address      = _ProfileStudent.Address;
                    tEntity.DepartmentId = _ProfileStudent.ClassId;
                    tEntity.Email        = _ProfileStudent.DepartmentId;
                    tEntity.ClassId      = _ProfileStudent.Email;
                    tEntity.PhoneNumber  = _ProfileStudent.PhoneNumber;


                    context.ProfileStudent.Update(tEntity);
                    context.SaveChanges();
                    return(Ok(true));
                }
                catch (Exception)
                {
                    return(Ok(false));
                }
            }
            return(Ok(false));
        }
Ejemplo n.º 2
0
        public IActionResult Update(string id, [FromBody] ProfileStudent profileStudent)
        {
            var entity = context.ProfileStudents.FirstOrDefault(e => e.ProfileId.Equals(id));

            if (entity != null)
            {
                try
                {
                    entity.FullName     = profileStudent.FullName;
                    entity.DepartmentId = profileStudent.DepartmentId;
                    entity.Email        = profileStudent.Email;
                    entity.Address      = profileStudent.Address;
                    entity.ClassId      = profileStudent.ClassId;
                    entity.PhoneNumber  = profileStudent.PhoneNumber;

                    context.ProfileStudents.Update(entity);
                    context.SaveChanges();

                    return(Ok("true"));
                }
                catch (Exception)
                {
                    return(Ok("false"));
                }
            }

            return(Ok("false"));
        }
 public IActionResult Create([FromBody] ProfileStudent _ProfileStudent)
 {
     try{
         _ProfileStudent.ProfileId = Guid.NewGuid() + "";
         context.ProfileStudent.Add(_ProfileStudent);
         context.SaveChanges();
         return(Ok(true));
     }catch {
         return(Ok(false));
     };
 }