logo
down
shadow

One-Many List box on a View and pull description from third entity


One-Many List box on a View and pull description from third entity

By : user2949454
Date : November 17 2020, 01:00 AM
help you fix your problem Try using following viewmodel and fill the TypeEvents from your controller
code :
public class EventViewModel
{
    public int Id {get;set;}
    public string Description {get;set;}
    public int TypeEventId    
    public IEnumerable<TypeEvent> TypeEvents {get;set;}

}


public class YourController
{
    [HttpGet]
    public ActionResult CreateEvent()
    {
        var viewModel = new EventViewModel();

        viewModel.TypeEvents = ... // fill Data for DropDownList here

        return View(viewModel);

    }

    [HttpPost]
    public ActionResult CreateEvent(EventViewModel viewModel)
    {
         // You should have all the data you need in the viewModel
    }
}
 @Html.DropDownListFor(m => m.TypeEventId, new SelectList(Model.TypeEvents,"Id","Description") )
@model Apps4KidsWeb.Models.AddAppViewModel

@using Apps4KidsWeb.Domain

<table>
    @foreach (KeyValuePair<int, int> item in Model.OperatingSystems)
    {
        <tr>
            <td>@operatingSystems[item.Value]</td>
            <td>
                @Ajax.ActionLink(
                                        "Remove",
                                        "RemoveOperatingSystem",
                                        "Admin",
                                        new { guid = Model.Guid, id = item.Key },
                                        new AjaxOptions
                                        {
                                            HttpMethod = "POST",
                                            InsertionMode = InsertionMode.Replace,
                                            UpdateTargetId = "operatingSystems"
                                        })</td>
        </tr>
    }
</table>
@model Apps4KidsWeb.Models.AddAppViewModel

@{
    ViewBag.Title = "Add App";
    ViewBag.CurrentPage = "Add App";
}
<div class="float">
    <h3>Categories</h3>
    <div id="categories">
        @Html.Partial("_Categories", Model)
    </div>



    @using (Ajax.BeginForm("AddCategory", "Admin",
    new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "categories", InsertionMode = InsertionMode.Replace }))
    {
        @Html.HiddenFor(model => model.Guid)
        @Html.EditorFor(model => model.Category)
        <input type="submit" value="Add" />    
    }
</div>
<div class="float">
    <h3>Operating Systems</h3>
    <div id="operatingSystems">
        @Html.Partial("_OperatingSystems", Model)
    </div>

    @using (Ajax.BeginForm("AddOperatingSystem", "Admin",
    new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "operatingSystems", InsertionMode = InsertionMode.Replace }))
    {
        @Html.HiddenFor(model => model.Guid)
        @Html.EditorFor(model => model.OS)
        <input type="submit" value="Add" />  
    }
</div>
<div class="clear"></div>
@using (Html.BeginForm("AddApp", "Admin"))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    @Html.HiddenFor(model => model.Guid)

    @Html.EditorForModel()

    <p>
        <input type="submit" value="Weiter" />
    </p>

}



@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
    /// <summary>
    /// Adds an operating system to the AddAppViewModel
    /// </summary>
    /// <param name="Guid">The Guid of the item</param>
    /// <param name="OS">The id of the operating system</param>
    /// <returns>PartialView _OperatingSystems</returns>
    [HttpPost]
    public ActionResult AddOperatingSystem(string Guid, int OS)
    {
        var viewmodel = EditedAppRepository.GetInstance().GetApp(Guid);
        viewmodel.AddOperatingSystem(OS);
        return PartialView("_OperatingSystems", viewmodel);

    }

    /// <summary>
    /// Removes an operating sytem from the AddAppViewModel
    /// </summary>
    /// <param name="Guid">The Guid of the item</param>
    /// <param name="id">The id of the operating system</param>
    /// <returns></returns>
    [HttpPost]
    public ActionResult RemoveOperatingSystem(string Guid, int id)
    {
        var viewmodel = EditedAppRepository.GetInstance().GetApp(Guid);
        viewmodel.RemoveOperatingSystem(id);
        return PartialView("_OperatingSystems", viewmodel);
    }
using Apps4KidsWeb.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Apps4KidsWeb.Models
{
    public class EditedAppRepository
    {
        #region singleton

        private static EditedAppRepository singleton;

        public static EditedAppRepository GetInstance()
        {
            if (singleton == null)
            {
                singleton = new EditedAppRepository();                
            }
            return singleton;
        }

        private EditedAppRepository()
        {
            this.repository = new Dictionary<string, AddAppViewModel>();
        }

        #endregion

        #region fields

        private Dictionary<string, AddAppViewModel> repository;

        #endregion

        #region methods

        public AddAppViewModel CreateNewApp(IApp app)
        {
            string guid = Guid.NewGuid().ToString();
            AddAppViewModel result = new AddAppViewModel(app) { Guid = guid };
            repository.Add(guid, result);
            result.Saved += OnAppSaved;
            return result;
        }

        public AddAppViewModel CreateNewApp(IRecommendationEx recommendation) 
        {
            string guid = Guid.NewGuid().ToString();
            AddAppViewModel result = new AddAppViewModel(recommendation) { Guid = guid };
            repository.Add(guid, result);
            result.Saved += OnAppSaved;
            return result;
        }

        public AddAppViewModel CreateNewApp()
        {
            string guid = Guid.NewGuid().ToString();
            AddAppViewModel result = new AddAppViewModel() { Guid=guid  };
            repository.Add(guid, result);
            result.Saved += OnAppSaved;
            return result;
        }

        public AddAppViewModel GetApp(string guid)
        {
            if (guid != null && repository.ContainsKey(guid))
            {
                return repository[guid];
            }
            return null;
        }

        private void OnAppSaved(object sender, EventArgs e)
        {
            AddAppViewModel model = (AddAppViewModel)sender;
            repository.Remove(model.Guid);
        }

        public byte[] GetAppPicture(string guid, int id)
        {
            return repository[guid].Images[id];
        }

        #endregion
    }
}


Share : facebook icon twitter icon
Cant retrieve short description in category list view

Cant retrieve short description in category list view


By : Masoud beigi
Date : March 29 2020, 07:55 AM
will help you I am trying to display each products description in the category list view like this: , Try this
Go to backend
Should I pass a list of menu items from every control action to a view or should I pull the list?

Should I pass a list of menu items from every control action to a view or should I pull the list?


By : RedCabbage
Date : March 29 2020, 07:55 AM
I wish this help you
If it did a pull from the layout then would MVC cache the results of the action?
Eclipse show view wizard says Use f2 to display the description... but where to set the description for the view

Eclipse show view wizard says Use f2 to display the description... but where to set the description for the view


By : Fangkai Yang
Date : March 29 2020, 07:55 AM
Does that help According to this bug report, the description is set in the description tag of the view in the plugin.xml.
An example:
code :
<view
    name="Sample View"
    icon="icons/sample.gif"
    category="test"
    class="test.views.SampleView"
    id="test.views.SampleView">
    <description>A very long descriptive text.
                 With a new line comes still more.
                 And more ... and more.</description>
</view>
list view with icon,title and description in Android

list view with icon,title and description in Android


By : s_hutch
Date : March 29 2020, 07:55 AM
I hope this helps you . insted of getBaseContext() use getActivity() or getApplicationContext()
How to pull a sorted list from Core Data when the entity has a relation to another entity

How to pull a sorted list from Core Data when the entity has a relation to another entity


By : Morteza Abolghasemi
Date : March 29 2020, 07:55 AM
wish of those help Vanadian solution did not work for me because the category relation is a one to many type. I read on the web that you cannot sort by a relation that has one-to-many and that was why the app was crashing.
The correct answer for my case is that it is not possible.
Related Posts Related Posts :
  • Console application doesn't obey Thread.Join
  • System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
  • Creating a scripting environment for a C# program
  • Is it reasonable to replace .Equals with a method rather than override it?
  • How I can capture multiple keys?
  • How to have all my classes default functionalities like .ToString method
  • Business Object properties: model as Objects or Enums?
  • Loading this assembly would produce a different grant set from other instances
  • How to call a method without first calling it's constructor in C#
  • Can't set a date time in one of my entity framework objects, says NullReferenceException
  • GETJob() Win32 Print spooler api 64bit The parameter is incorrect, how to fix?
  • Switch Case Causing Trouble In Going To A particular Function
  • Switch Case Calling A Function Based On The User's Choice
  • Accessing WebBrowser on different Threads
  • CPU Usage Avoid 100% With Environment.ProcessorCount?
  • Select distinct categories from database
  • C# app getting Watson dialog when calling TerminateProcess
  • The underlying provider failed on Open in entity framework connection
  • Compile a library without checking references
  • Can we create and access a registry key in HKEY_LOCAL_MACHINE without running application with admin permissions in C#
  • Control light intensity with a UI slider
  • Threading (Does these threads exits or aborts itself?)
  • Change the function of a button if Logged in
  • how to accept value in date format in textbox in C# windows form?
  • remove the lines from RichtextBox?
  • How to call String.Split that takes string as separator?
  • Specify task timeout in parallel linq to objects
  • comparing two custom objects to prevent duplicates
  • How to Print Text from ComboBox into a MessageBox
  • How can I do a Func<object[],Expression<Func<T,bool>>> dynamic?
  • C# SqlDataReader No data exists for the row/column
  • My code is not giving the desired output
  • Is it possible to have multiple MVC routes point to the same controller/view?
  • Updating Listbox results in " Invalid cross-thread access."
  • Finding Elbow Angle with Kinect
  • Host a mvc web api application in the sub-folder of a website
  • How to generate a sequential unique id in a thread-safe way
  • How to add a separator to a WPF combobox that is databound?
  • optimize linq query with related entities
  • Optimize this code for large input
  • Is there any way to clear all list box short way?
  • ACR122 Device Programming sample does not find reader
  • Parallel Library: does a delay on one degree of parallelism delay all of them?
  • How to convert a var which contains Long to an Long[]
  • Quickly prune and create valid data combinations
  • Get 3 parameters out of a Dictionary<string, Dictionary<string Action>>
  • Regex IsMatch taking too long to execute
  • Shuffling divs using C# behindcode
  • ASP.NET Project and IE10 Compatibility Mode issues in Windows 7
  • Why can't I loop through this dictionary?
  • RavenDB Stream for Unbounded Results - Connection Resilience
  • How to remove the focus border of a CheckBox in C# Visual Studio?
  • Exception while using String.Format "Index (zero based) must be greater than or equal to zero and less than the siz
  • Caching an LDAP connection
  • C# How to detect kill event sender
  • How to Display Splashscreen and login form at same time using c#
  • Read .sql script with parameters
  • Why would I need to compile/generate methods/code at runtime?
  • Unable to create a constant value of type 'Project.Models.Subcategory'. Only primitive types or enumeration types are su
  • How to run possibly synchronous or possibly asynchronous code?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org