public async Task<ActionResult> EditConsumer(int user_id, int consumer_id, ConsumerViewModel consumerObj) { try { var user = await _mLearningService.GetObjectWithId<User>(user_id); var consumer = await _mLearningService.GetObjectWithId<Consumer>(consumer_id); //Copy Ids consumerObj.User.id = user_id; consumerObj.Consumer.id = consumer_id; consumerObj.User.password = EncryptionService.encrypt(consumerObj.User.password); //Fields which doesn't update consumerObj.User.is_online = user.is_online; consumerObj.User.social_id = user.social_id; consumerObj.User.updated_at = user.updated_at; consumerObj.User.created_at = user.created_at; consumerObj.Consumer.updated_at = consumer.updated_at; consumerObj.Consumer.created_at = consumer.created_at; consumerObj.Consumer.User_id = consumer.User_id; //Update DB await _mLearningService.UpdateObject<User>(consumerObj.User); await _mLearningService.UpdateObject<Consumer>(consumerObj.Consumer); return RedirectToAction("Index", new { id = UserID }); } catch { return RedirectToAction("Index", new { id = UserID }); } }
async public Task<ActionResult> CreateConsumer(ConsumerViewModel consumerObj) { try { consumerObj.User.password = EncryptionService.encrypt(consumerObj.User.password); await _mLearningService.CreateAndRegisterConsumer(consumerObj.User,InstitutionID); return RedirectToAction("Index", new { id = UserID }); } catch { return RedirectToAction("Index", new { id = UserID }); } }