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")); }
public async void InsertAccount(Account account) { using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>())) { context.Add(account); await context.SaveChangesAsync(); } }
public async void DeletePendingAccount(string strEmail) { using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>())) { PendingAccount pendingAccount = await context.PendingAccount.SingleOrDefaultAsync(p => p.Email == strEmail); context.PendingAccount.Remove(pendingAccount); await context.SaveChangesAsync(); } }
private async void InsertTechnician(Technician technician, string strEmail) { using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>())) { long lngId = await context.Account.Where(a => a.Email == strEmail).Select(a => a.IdAccount).SingleOrDefaultAsync(); technician.IdAccount = lngId; context.Add(technician); await context.SaveChangesAsync(); } }
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> FileTest([Bind("File")] FileViewModel viewModel) { using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>())) { var testFile = new TestFile { }; using (var memoryStream = new MemoryStream()) { await viewModel.File.CopyToAsync(memoryStream); testFile.FileTest = memoryStream.ToArray(); } context.Add(testFile); await context.SaveChangesAsync(); } return(RedirectToAction("ShowFiles", "Application")); }
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")); }