c# – How to get pass multiple models in one view using Razor in asp.net mvc?

I have multiple models and my submitRequest is pointing to a DAL(Data-Access Layer) that has a table definition for my fields. I am struggling to save these fields to the access layer. At first was able to save it using one(TbTrainingRegForm only). Hence my form now uses different controls that points each to different models. Please tell me help on my logic below to see where this is not working well on my View.

// Controller
public ActionResult SaveRegForm()
            ViewBag.Message = "Details saved successfull";
            return View(db.TrainingRegs.ToList());

       public ActionResult SubmitRegDetails()
            return View();

        public ActionResult SubmitRegDetails((Bind(Include= "Id, Title, FirstName, LastName, Position, Company, StreetAddress, StreetAddressLine, City, StateProvince, ZipCode,Email, CellNumber, DietaryRequirement"))TrainingRegForm eNtsaTraining)
                eNtsaTraining.Id = Guid.NewGuid();
                return RedirectToAction("SaveRegForm");

            // Validates when empty.
                return RedirectToAction("SaveRegForm");
            return View(eNtsaTraining);
// Data-Access-Layer
namespace eNtsaRegistrationTraining.DAL
    public class eNtsaRegistration:DbContext

        public eNtsaRegistration() : base("eNtsaRegistration")
        }  public DbSet<TrainingRegForm> TrainingRegs { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
// Models
namespace eNtsaRegistrationTraining.Models
    public class TrainingRegForm
        public Guid? Id { get; set; }
        public string Title { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Position { get; set; }
        public string Company { get; set; }

        public string StreetAddress { get; set; }

        public string StreetAddressLine { get; set; }

        public string City { get; set; }
        public string StateProvince { get; set; }

        public int ZipCode { get; set; }

        public string Country { get; set; }

        public string Email { get; set; }

        (Required(ErrorMessage = "This field is required"))
        public string CellNumber { get; set; }
        public string DietaryRequirement { get; set; }

    public class RegViewAndRoleViewModel
        public DietViewModel DietMain { get; set; }

        public TrainingRegForm RegForm { get; set; }

        public DropDownViewModel ListCountries { get; set; }
        public RegistrationTrainingForm HomeModel { get; set; }
        public RoleViewModel RoleViewModelData { get; set; }

// View
@using eNtsaRegistrationTraining.Models
@model RegViewAndRoleViewModel
    ViewBag.Title = "SubmitRegDetails";
@using (Html.BeginForm("SubmitRegDetails", "Home", FormMethod.Post))


8 – Is there a way to pass custom data to a form template?

I have been tasked to customize a view, and I have been struggling with its exposed form, because I need to display some informations. Here is how it should look:


These elements act as a checkbox, but the number on the right is the number of nodes that have this tag linked.

So far, I have nothing code related, because I simply don’t know how to handle this. The theme itself would accept an array of array, each of them containing the checkbox’s text, its value, and this number, like so:

tabs: [
      label: "Topics",
      filtersType: "tag",
      filterName: "loremField[]",
      filters: [
          id: "lorem1",
          label: "Loremi",
          items: "5"
          id: "lorem2",
          label: "Loremi",
          items: "15"

However, I’m not able to either pass this “items” key to either the form, and I’m not sure at all that I can customize the input from the hook form alter. For a reference, here is the template:

<div class="c-tag-filters">
  {% for item in filters %}
    <div class="c-tag-filters__item">
      <input id="{{item.id}}" name="{{ filters.filterName }}" class="c-tag-filters__item__input" type="checkbox">
      <div class="c-tag-filters__item__content">
        <label for="{{item.id}}">{{item.label}} <span class="c-tag-filters__item__content--nb">{{ item.items }}</span></label>
  {% endfor %}

So, how should I proceed in this case?

Thank you in advance

beginner – Should I unpack a Maybe with maybe or pass value around

I’m beginning (for the third time in 5 years) to learn Haskell and decided to do a “More or less” console game (game pick a random number, you then have to guess which).

First the code, then my question :

import System.Random  
import Text.Read(readMaybe)

main :: IO ()
main = do 
  gen <- getStdGen
  let maxSecret = 1000
  let (secret, newGen) = randomR (1,maxSecret) gen :: (Int, StdGen)

  -- putStrLn $ show secret
  let oracle = compareToSecret secret
  askForNumber oracle 1 (1, maxSecret)

data Guess = SecretIsLess | SecretIsMore | Win deriving (Show)

askForNumber :: (Int -> Guess) -> Int -> (Int, Int) -> IO ()
askForNumber oracle tries range = do
  let (min, max) = range
  putStrLn $ "Guess the number between " ++ (show min) ++ " and " ++ (show max) ++ " !"
  guessInput <- getLine
  let guess = readMaybe guessInput :: Maybe Int

  case (oracle) <$> guess of 
            Just SecretIsMore -> do
                  putStrLn "Guess more !"
                  askForNumber oracle (tries+1) (maybe min id guess, max)
            Just SecretIsLess -> do
                  putStrLn "Guess less !"
                  askForNumber oracle (tries+1) (min, maybe max id guess)
            Just Win -> do
                  putStrLn "You win !"
                  putStrLn $ "It took you " ++ (show tries) ++ " tries."
                  return ()
            Nothing -> do
                  putStrLn "That is not a number"
                  askForNumber oracle tries range
compareToSecret :: Int -> Int -> Guess
compareToSecret secret guess
  | secret > guess = SecretIsMore
  | secret < guess = SecretIsLess
  | secret == guess = Win

I’d like to improve that code to make it idiomatic and learn in the process.

I made a choice : at first I had
compareToSecret :: Int -> Int -> (Guess, Int)
and in the case of I had something like
Just (SecretIsMore, newmin) -> do askForNumber oracle (tries+1) (newmin, max)

Do you think it’s better to kind of unpack with maybe there or to pass the value around and keep it pure ? Or is there another solution ?

8 – How to pass pagination value to drupal view programatically?

I have a view with contextual filter and I render the view through program as below

$view = Views::getView('schedule');
$render_array = $view->buildRenderable('rest_export_1',$args);
$rendered = Drupal::service('renderer')->renderRoot($render_array);

The view is paged with 5 results in each page. How do I pass the value to get results from the second page of the view?

dnd 5e – How many turns does it take for an unseen servant to pass a healing potion in combat?

Unseen servant reads:

Once on each of your turns as a bonus action, you can mentally command
the servant to move up to 15 feet and interact with an object. The
servant can perform simple tasks that a human servant could do, such
as fetching things, cleaning, mending, folding clothes, lighting
fires, serving food, and pouring wine. Once you give the command, the
servant performs the task to the best of its ability until it
completes the task, then waits for your next command.

Assume I used my bonus action to command it to give the healing potion in my pocket to another character, and that it is within reach when I do. It would take a player one turn to complete the task. A free item interaction to draw the potion, then movement, followed by an action to safely pass it over. But the unseen servant seems to be solely capable of movement then a single item interaction.

How many turns would it take for it to perform this task? And if two or more are necessary what is the order of operations? Can it move after interacting with an object?

how to pass / update data between UITableViews in swift?

I have 2 ViewControllers, both contain UITablView:
enter image description here

What I am trying to achieve is that as follows:
enter image description here

It is much like a survey/ choice pages where in InputVC list of possible choices are displayed and asks the user to choose, and when the User taps the one of the cells in the InputVC, it then Should take the user to DetailVC where the user can choose, and after the choice is made, choices should reflect back in the InputVC, how is that possible? i am stuck in this part..

it could be done with func prepareForSegue( with Identifier: "" method, but I am using Coordinator pattern protocol as the backbone navigation method..

If I, lets say create separate VC for each cell in a row of UITableView, I know that I end with as much VCs as the number of cells are increased.. . which is a bad method.. .

So far, I have this: In InputVC, a cellClass:

class CellForDetail: UITableViewCell {

@IBOutlet weak var title: UILabel!
@IBOutlet weak var textField: UITextField!

func configCell(with model: ModelForTitle ) {
    title?.text = model.title
    textField?.placeholder = model.placeholder
    textField?.accessibilityLabel = model.placeholder
    title?.isUserInteractionEnabled = false
    textField?.isUserInteractionEnabled = false
func setInterUserInterAction(for cell: UITableViewCell, at indexPath: IndexPath) {
    if indexPath.row == 10 || indexPath.row == 11  {
        textField?.isUserInteractionEnabled = true
        title.isUserInteractionEnabled = false
    else {

and in func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) :

   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    NSLog("Cell is tapped")
    switch indexPath.row {
    case 0:
        if let indexPathForSelectedRow = tableView.indexPathForSelectedRow {
           let DestinationVC = CarDetailDataTableViewController()
            DestinationVC.//  ????

since i am stuck, my DetailVC contains almost no useful method to show here.. .

and my model is just a simple Struct where I store one TitleLabel as string value:

struct ModelForDealer {
var dealerName: String?


let modelForDealer: (ModelForDealer) = (
           ModelForDealer(dealerName: "General Motors"),
           ModelForDealer(dealerName: "General Motors"),
           ModelForDealer(dealerName: "General Motors"),
           ModelForDealer(dealerName: "General Motors"),
           ModelForDealer(dealerName: "General Motors"),
           ModelForDealer(dealerName: "General Motors"))

anyone has an idea?

bitcoin core – How can I use my pass phrase from 2009 to recover my wallet?

I believe the only possible answer for this time (assuming you mean 2009, no wallets existed before then with recovery mnemonics) is that the wallet was blockchain.info. Different to now, at the time it used a “recovery mnemonic”, which was an encoding of your password rather than the keys in your wallet. Unfortunately if this is the case you need to also know either the ‘wallet identifier’ (looks like fbb4b1dd-1b30-4cc2-b745-b586e4f3cb57), or the original wallet.json.aes file.

8 – Pass values from one from to another

I need to query data based on the ‘username’ on Form-1 and pass the values of ?>that user to Form-2.

How do I populate Form -2 from data from Form -1 submitForm?
Form-1 is custom form and Form -2 is node form.

Form 1:
This form lets user search and select their username

Code for this form:

‘#placeholder’ => t(‘Seach by username’),
‘#title’ => t(‘ULM Username’),
‘#autocomplete_route_name’ => ‘fixx_helper.myautocomplete’

$form(‘actions’)(‘submit’) = (
‘#type’ => ‘submit’,
‘#value’ => $this->t(‘Save’),
‘#button_type’ => ‘primary’,

return $form;

* {@inheritdoc}
public function submitForm(array &$form, FormStateInterface $form_state)


> **Form 2:**

>(!(This is a node form where data needs to be populated from form-1)(2))(2)
(!(`enter image description here`)(2))(2)

$database = Drupal::database();
$my_query = $database->query(“select distinct username from banner_exports.ws_students where username like ‘$input%'”);

while($result = $my_query->fetchAssoc())
$matches() = array(‘value’ => $result(‘username’), ‘label’ => $result(‘username’));
return new JsonResponse($matches);


$new_query = $database->query(“select * from banner_exports.ws_students”);

name: Lookup Username Autocomplete
description: This adds search username function.
core: 8.x
package: Custom
type: module

>**.module file**

Routing file:

path: ‘/lookupform’
_title: ‘Lookup User Autocomplete’
_form: ‘Drupallookupformlookupform’
_permission: ‘access content’

path: ‘auto_lookupform’
_controller: ‘DrupallookupControllerAutocompleteController::handleAutocomplete’
_format: json
_access: ‘TRUE’

pass query string from sharepoint page to powerapps form

To do that follow the below steps:

Step 1:

  1. Embed the PowerApps form inside the SharePoint online page using the embed web part.
  2. The Power Apps Embedded Inside Tag On A Page. Now We Have Two Different Modern Pages Each Having Power App Forms.

Step 2: How to Pass the dynamic parameters?

Pass The Parameter On Click On Any Item From One Page To Another Using Navigate Function.
Navigate(ScreenToNavigate, ScreenTransition.Fade, { Argument1: 04 , Argument2: SomeText })
In Another Page You Need To Collect/Catch This Parameter Value, You Can Get That By Different Functions,
Param(“ParamName”) Functions Or By Direct Assigning Values.
LookUp('***** Slips', 'Case Title'.Value = Param("(ParamName)"))
Filter('Case ****’,CaseTitle.Value=SelectParamName.SelectedText.Value)

Note – Limitation

In the above approach, the problem Is In Another Screen/Page Parameter Value Cannot Be Read As The Forms Are Embedded In Iframe. This Has Been Raised In Microsoft Support And MS Had Considered this as limitation.

How to overcome the above challenge or what is the alternate approach?

The Solution In This Scenario Is To Create Multiple Screens In The Same Power App Form And Then Embed
this Form In SharePoint Modern Page. Above Functions Remain Same But Now As There Is No Iframe It
Reads The Parameter And Get The Correct Value.

For more details refer to the below article: