public ActionResult Create([Bind(Include = "ID,InstrumentID,Year,Annual,Q1,Q2,Q3,Q4,Currency,InstrumentCode,CreatedOn,CreatedBy")] CompanyEarning companyEarning)
        {
            GetViewDropDownData();

            var companyEarnings = db.usp_GetCompanyEarnings().Where(ce => ce.InstrumentCode == companyEarning.InstrumentCode && ce.Year == companyEarning.Year).ToList();

            if (companyEarnings.Count() > 0)
            {
                ModelState.AddModelError("Company Earnings", "Company Earnings Information has already been updated for the selected Symbol.");
            }
            else
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        db.CompanyEarnings.Add(companyEarning);
                        db.SaveChanges();
                        TempData["Message"] = "Company Earning Successfully Added";
                        return(RedirectToAction("Index", new { Symbols = companyEarning.InstrumentCode }));
                    }
                    catch (Exception exp)
                    {
                        ViewData["Message"] = "Error Adding Company Earnings.";
                        ModelState.AddModelError("Error", "An error has occured please contact Administrator");
                        log.Error(exp);
                        return(View(companyEarning));
                    }
                }
            }

            //ViewBag.InstrumentCode = new SelectList(db.Instruments, "InstrumentCode", "ISIN", companyEarning.InstrumentCode);
            return(View(companyEarning));
        }
        // GET: CompanyEarnings/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompanyEarning companyEarning = db.CompanyEarnings.Find(id);

            if (companyEarning == null)
            {
                return(HttpNotFound());
            }
            return(View(companyEarning));
        }
        // GET: CompanyEarnings/Edit/5
        public ActionResult Edit(int?id)
        {
            GetViewDropDownData();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompanyEarning companyEarning = db.CompanyEarnings.Find(id);

            if (companyEarning == null)
            {
                return(HttpNotFound());
            }
            // ViewBag.InstrumentCode = new SelectList(db.Instruments, "InstrumentCode", "ISIN", companyEarning.InstrumentCode);
            return(View(companyEarning));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         CompanyEarning companyEarning = db.CompanyEarnings.Find(id);
         db.CompanyEarnings.Remove(companyEarning);
         db.SaveChanges();
         TempData["Message"] = "Company Earning was successfully deleted.";
         return(RedirectToAction("Index"));
     }
     catch (Exception exp)
     {
         TempData["Message"] = "Error Editing Company Earnings.";
         ModelState.AddModelError("Error", "An error has occured please contact Administrator");
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Edit([Bind(Include = "ID,InstrumentID,Year,Annual,Q1,Q2,Q3,Q4,Currency,InstrumentCode,ModifiedOn,ModifiedBy")]  CompanyEarning companyEarning)
 {
     GetViewDropDownData();
     // if(companyEarning.Currency1.CurrencyID)
     if (ModelState.IsValid)
     {
         try
         {
             db.Entry(companyEarning).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             TempData["Message"] = "Company Earning was Successfully Edited.";
             return(RedirectToAction("Index", new { Symbols = companyEarning.InstrumentCode }));
         }
         catch (Exception exp)
         {
             ViewData["Message"] = "Error Editing Company Earnings.";
             ModelState.AddModelError("Error", "An error has occured please contact Administrator");
             return(View(companyEarning));
         }
     }
     //ViewBag.InstrumentCode = new SelectList(db.Instruments, "InstrumentCode", "ISIN", companyEarning.InstrumentCode);
     return(View(companyEarning));
 }