asp.net mvc

Hi Guys,

I got confuse of how to display images through my database to the image path:

Here is what I'm trying to do.

Actually what I'm doing - i'm passing id to the controller and popup the window below:
function Showitems(id) {
            var url = "@System.Configuration.ConfigurationManager.AppSettings["webUrl"]";
            url = url + "Inventory/Itemsrefer/" + id;
            window.open(url, '_blank',"width=1200, height=800", 'resizable=No');
        }

Open in new window


"WebUrl" in web.config = <add key="webUrl" value="http://testerp.alt.com/" />

This is my popup window where the image should come up:



@{
    ViewBag.Title = "Picture";
    Layout = null;
}

@model ALThompsonCRM.Models.ViewModel.ItemPic

<center>
    <div>
        <td>
            <div id="divMyTags">
                <div class="existingTag">
                    <a class="closeButton" href="#" onclick="deleteme(@Model.picid);"></a>
                    <img alt="@Model.itemTitle" width="300" height="300" id="@Model.itemID" src="http://http://testerp.alt.com/doc/item_pics/@Model.picName" />
                </div>
            </div><br />
            @*<a href="#" onclick="makememain(@Model.picid)">Make this main picture</a>*@
        </td>

    </div>
</center>

Open in new window



I have database that much between item number to picture name which located in some path that i have access to.

Here is my server side code which I really don't know what i did:):
  public ActionResult Picture(int id)
        {
            ALThompsonCRMEntities db = new ALThompsonCRMEntities();
            ItemPic objpic = new ItemPic();
            var img = db.t_Item_Picture.Where(p => p.ItemId == id);

            if (id != null)
            {
                string docPath = ConfigurationManager.AppSettings["docPath"].ToString();

            }

            return View(objpic);

        }

Open in new window


Thanks ,
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Moti Mashiah.NET DeveloperAuthor Commented:
Solved the issue:

Here is the solution
 public ActionResult Picture(int id)
        {
            ALThompsonCRMEntities _db = new ALThompsonCRMEntities();
            var ip = _db.t_Item_Picture.Where(p => p.ItemId == id).Select(p => new ItemPic { picid = p.Id, picName = p.Pic_Name, itemTitle = p.Item_Title, itemID = p.ItemId }).ToList();
            ItemPic ipc = new Models.ViewModel.ItemPic();
            ipc.itemID = id;
            ipc.lstPics = ip;
            if (ip.Count <= 0)
            {
                rmsmasterdbtestEntities _rms = new rmsmasterdbtestEntities();
                var im = _rms.Items.Where(p => p.ID == id).FirstOrDefault();
                ipc.itemTitle = im.Description;
                ipc.picName = im.PictureName;
            }
            else
            {
                int i = 0;
                foreach (var itm in ip)
                {
                    if (i == 0)
                    {
                        ipc.itemTitle = itm.itemTitle;
                        ipc.picName = itm.picName;
                        i = 1;
                    }
                }
            }

            return View(ipc);
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.