//Home Page
        public ActionResult Index()
        {
            ActionResult oResponse = null;

            //Give the list to the view to display
            try
            {
                List <InvoiceDO> allInvoices    = _invoiceDataAccess.ViewInvoices();
                List <InvoiceBO> mappedInvoices = new List <InvoiceBO>();
                foreach (InvoiceDO dataObject in allInvoices)
                {
                    mappedInvoices.Add(HighestProfitMap.InvoiceDOtoInvoiceBO(dataObject));
                }
                List <KeyValuePair <BoatPO, int> > topDisplay = new List <KeyValuePair <BoatPO, int> >();
                List <KeyValuePair <Int64, int> >  topBoats   = InvoiceBLO.TopBoatsByInvoiceCount(mappedInvoices);
                foreach (KeyValuePair <Int64, int> record in topBoats)
                {
                    BoatDO dataObject = _boatDataAccess.ViewBoatByID(record.Key);
                    BoatPO boat       = BoatMap1.BoatDOtoBoatPO(dataObject);
                    topDisplay.Add(new KeyValuePair <BoatPO, int>(boat, record.Value));
                }
                oResponse = View(topDisplay);
            }
            catch (Exception ex)
            {
                logger.Log("Fatal", ex.Source, ex.TargetSite.ToString(), ex.Message, ex.StackTrace);
            }
            finally
            {
            }
            return(oResponse);
        }
Example #2
0
        public ActionResult UpdateSailboat(Int64 BoatID)
        {
            BoatDO item         = _boatDataAccess.ViewBoatByID(BoatID);
            BoatPO boatToUpdate = BoatMap1.BoatDOtoBoatPO(item);

            return(View(boatToUpdate));
        }
Example #3
0
        public ActionResult AddInvoice(InvoicePO form)
        {
            ActionResult oResponse = null;

            try
            {
                if (ModelState.IsValid)
                {
                    //defines variables for boat .. and double days
                    BoatDO boat = _boatDataAccess.ViewBoatByID(form.BoatID);
                    double days = form.DateReturned.Subtract(form.DateChartered).TotalDays;
                    //if greater than 0
                    if (days > 0)
                    {
                        //amount due = cost x days
                        form.AmountDue  = boat.CostperDay * (decimal)days;
                        form.CostperDay = boat.CostperDay;
                        InvoiceDO dataObject = InvoiceMap1.InvoicePOtoDO(form);
                        _invoiceDataAccess.AddInvoice(dataObject);
                        oResponse = RedirectToAction("ViewInvoice", "Invoice");
                    }
                    else
                    {
                        TempData["ErrorMsg"] = "Date Returned can not be less than Date Chartered.";
                        //TODO: fill select items
                        oResponse = View(form);
                    }
                }
                else
                {
                    oResponse = View(form);
                }
            }
            catch (Exception ex)
            {
                logger.Log("Fatal", ex.Source, ex.TargetSite.ToString(), ex.Message, ex.StackTrace);
            }
            finally { }
            return(oResponse);
        }