public async Task<ActionResult> Edit(int user_id,int head_id,int inst_id, AdminViewModel adminObj) { try { var user = await _mLearningService.GetObjectWithId<User>(user_id); var head = await _mLearningService.GetObjectWithId<Head>(head_id); var institution = await _mLearningService.GetObjectWithId<Institution>(inst_id); //Copy Ids adminObj.User.id = user_id; adminObj.Head.id = head_id; adminObj.Inst.id = inst_id; adminObj.User.password = EncryptionService.encrypt(adminObj.User.password); //Fields which doesn't update adminObj.User.email = user.email; adminObj.User.is_online = user.is_online; adminObj.User.social_id = user.social_id; adminObj.User.image_url = user.image_url; adminObj.User.updated_at = user.updated_at; adminObj.User.created_at = user.created_at; adminObj.Head.updated_at = head.updated_at; adminObj.Head.created_at = head.created_at; adminObj.Head.User_id = head.User_id; adminObj.Inst.created_at = institution.created_at; adminObj.Inst.updated_at = institution.updated_at; //Update DB _mLearningService.UpdateObject<User>(adminObj.User); _mLearningService.UpdateObject<Head>(adminObj.Head); _mLearningService.UpdateObject<Institution>(adminObj.Inst); return RedirectToAction("Index"); } catch { return View("Index"); } }
async public Task<ActionResult> Create(AdminViewModel adminObj) { try { adminObj.User.password = EncryptionService.encrypt(adminObj.User.password); await _mLearningService.CreateInstitution(adminObj.Inst, adminObj.Head, adminObj.User); return RedirectToAction("Index"); } catch { return RedirectToAction("Index"); } }