public ActionResult AddShipment(ShipmentVM viewModel)
        {
            ActionResult oResponse = null;

            if (Session["UserName"] != null && (int)Session["UserLevel"] <= 2)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        IShipmentInfoDO shipmentform = ShipmentMap.MapPOtoDO(viewModel.Shipment);
                        //call to method in DAL to view shipment by producerID
                        _ShipmentAccess.InsertShipment(shipmentform);
                    }
                    catch (Exception e)
                    {
                        if (e.Message.Contains("duplicate"))
                        {
                            viewModel.ErrorMessage = String.Format("There is already a {0} in the database.", viewModel.Shipment.ShipmentID);
                        }
                        else
                        {
                            viewModel.ErrorMessage = "We apologize but we were unable to handle your request at this time.";
                        }
                    }
                    finally
                    {
                        //nothing to do here
                    }
                    if (viewModel.ErrorMessage == null)
                    {
                        oResponse = RedirectToAction("ViewShipments", "Shipment");
                    }
                    else
                    {
                        //Data call here to re-get the locations and producers.
                        viewModel.Shipment.ProducerDDL = PopulateProducersDDL();
                        viewModel.Shipment.LocationDDL = PopulateLocationsDDL();

                        oResponse = View(viewModel);
                    }
                }
                else
                {
                    //Data call here to re-get the locations and producers.
                    //placed into method

                    viewModel.Shipment.ProducerDDL = PopulateProducersDDL();
                    viewModel.Shipment.LocationDDL = PopulateLocationsDDL();

                    oResponse = View(viewModel);
                }
            }
            else
            {
                oResponse = RedirectToAction("Login", "User");
            }
            return(oResponse);
        }
        public ActionResult UpdateShipment(ShipmentVM changeshipment)
        {
            ActionResult oResult = null;

            if (Session["UserName"] != null && (int)Session["UserLevel"] <= 2)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        IShipmentInfoDO updateShipment = ShipmentMap.MapPOtoDO(changeshipment.Shipment);
                        //call method from DAL to change the info in db
                        _ShipmentAccess.UpdateShipment(updateShipment);
                    }
                    catch (Exception e)
                    {
                        //what to do with exception what to write

                        if (e.Message.Contains("duplicate"))
                        {
                            changeshipment.ErrorMessage = "Unable to process request, duplicate record already exists";
                        }
                        else
                        {
                            changeshipment.ErrorMessage = "We apologize but we were unable to handle your request at this time.";
                        }
                    }
                    finally
                    {
                    }

                    if (changeshipment.ErrorMessage == null)
                    {
                        //if no errors with update, return to list of shipments to see if info was changed
                        oResult = RedirectToAction("ViewShipments", "Shipment");
                    }
                    else
                    {
                        oResult = RedirectToAction("UpdateShipment", "Shipment");
                    }
                }
                else
                {
                    oResult = View(changeshipment);
                }
            }
            else
            {
                oResult = RedirectToAction("Login", "User");
            }
            return(oResult);
        }