예제 #1
0
        public async Task <IActionResult> UpdateProfileTechnician([Bind("IdAccount, Name, Telephone")] Technician technician)
        {
            if (GetCurrentUserID() != technician.IdAccount)
            {
                return(BadRequest());
            }

            try
            {
                using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>()))
                {
                    Technician newTechnician = await context.Technician.SingleOrDefaultAsync(t => t.IdAccount == technician.IdAccount);

                    if (newTechnician == null)
                    {
                        return(NotFound());
                    }

                    newTechnician.Telephone = technician.Telephone;

                    context.Update(newTechnician);
                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }


            return(RedirectToAction("Index"));
        }
예제 #2
0
        private async void ChangePassword(string strEmail, string strPassword)
        {
            using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>()))
            {
                Account account = context.Account.SingleOrDefault(a => a.Email == strEmail);

                if (account != null)
                {
                    account.Password = StrToArrByte(strPassword);
                    context.Update(account);
                    await context.SaveChangesAsync();
                }
            }
        }
예제 #3
0
        public async Task <IActionResult> UpdateProfileStudent(ProfileViewModel model)
        {
            if (GetCurrentUserID() != model.Student.IdAccount)
            {
                return(BadRequest());
            }

            try
            {
                using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>()))
                {
                    Student newStudent = await context.Student.SingleOrDefaultAsync(s => s.IdAccount == model.Student.IdAccount);

                    if (newStudent == null)
                    {
                        return(NotFound());
                    }

                    newStudent.Telephone  = model.Student.Telephone;
                    newStudent.PostalCode = model.Student.PostalCode;
                    newStudent.StudentNum = model.Student.StudentNum;
                    newStudent.Credits    = model.Student.Credits;
                    newStudent.PostalCode = model.PostalCode1 + "-" + model.PostalCode2;

                    context.Update(newStudent);

                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(RedirectToAction("Index"));
        }