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")); }
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(); } } }
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")); }