Exemplo n.º 1
0
 public ActionResult AddFinance(SearchFinanceModel model)
 {
     Session["Finance"] = null;
     IEnumerable<FinanceModel> objBE;
     using (var client = new HttpClient())
     {
         model.addFinance.insertUserId = base.CurrentUserID;
         client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["APIURI"]);
         client.DefaultRequestHeaders.Accept.Add(
             new MediaTypeWithQualityHeaderValue("application/json"));
         HttpResponseMessage response = client.PutAsJsonAsync("finance/SaveFinanceActivity", model.addFinance).Result;
         if (response.IsSuccessStatusCode)
         {
             string jsonResult = response.Content.ReadAsStringAsync().Result;
             if (!string.IsNullOrEmpty(jsonResult) && !jsonResult.Equals("[]"))
             {
                 objBE = JsonConvert.DeserializeObject<IEnumerable<FinanceModel>>(jsonResult);
                 model.addFinance.finance = objBE;
             }
             else
                 model.addFinance.finance = null;
         }
         model.activityType = (IEnumerable<SelectListItem>)Session["ActivityType"];
         model.processorCompany = (IEnumerable<SelectListItem>)Session["Processor"];
         model.addFinance.activityType = (IEnumerable<SelectListItem>)Session["ActivityType"];
         model.addFinance.processorCompany = (IEnumerable<SelectListItem>)Session["Processor"];
         ViewBag.SuccessMsg = Pecuniaus.Resources.Finance.Finance.FinanceAddedSuccessfully;
     }
     return View("Index", model);
 }
Exemplo n.º 2
0
 public ActionResult DelActivity(long id)
 {
     var apiMethod = string.Format("finance/DeleteActivity/" + id);
     var response = BaseApiData.PutAPIData(apiMethod, null);
     if (response.StatusCode == System.Net.HttpStatusCode.OK)
     {
         var model = new SearchFinanceModel();
         if (Session["Financemodel"] != null)
         {
             model = (SearchFinanceModel)Session["Financemodel"];
             var filterlist = from f in model.finance
                              where f.ActivityId != id
                              select f;
             model.finance = filterlist;
             Session["Financemodel"] = model;
         }
         ViewBag.SuccessMsg = "Finance Activity Deleteded Successfully";
     }
     return Json("OK");
 }
Exemplo n.º 3
0
        public ActionResult Index(SearchFinanceModel model, string command)
        {
            switch (command)
            {
                case "search":
                    Session["Finance"] = null;

                    IEnumerable<FinanceModel> objBE;
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["APIURI"]);
                        client.DefaultRequestHeaders.Accept.Add(
                            new MediaTypeWithQualityHeaderValue("application/json"));
                        HttpResponseMessage response = client.PostAsJsonAsync("finance/SearchFinance", model).Result;
                        if (response.IsSuccessStatusCode)
                        {
                            string jsonResult = response.Content.ReadAsStringAsync().Result;
                            objBE = JsonConvert.DeserializeObject<IEnumerable<FinanceModel>>(jsonResult);
                            model.finance = objBE;
                            if (!string.IsNullOrEmpty(jsonResult) && !jsonResult.Equals("[]"))
                            {
                                GridView gv = new GridView();
                                gv.DataSource = objBE;
                                gv.DataBind();
                                Session["Finance"] = gv;
                            }
                        }
                    }
                    model.activityType = (IEnumerable<SelectListItem>)Session["ActivityType"];
                    model.processorCompany = (IEnumerable<SelectListItem>)Session["Processor"];
                    model.addFinance = new AddFinanceModel();
                    model.addFinance.activityType = (IEnumerable<SelectListItem>)Session["ActivityType"];
                    model.addFinance.processorCompany = (IEnumerable<SelectListItem>)Session["Processor"];
                    Session["Financemodel"] = model;
                    return View(model);
                case "excel":
                    if (Session["Finance"] != null)
                    {
                        ExportToExcel((GridView)Session["Finance"], "Finance.xls");
                        ViewBag.SuccessMsg = Pecuniaus.Resources.Finance.Finance.ExportSuccessfully;
                    }
                    model.activityType = (IEnumerable<SelectListItem>)Session["ActivityType"];
                    model.processorCompany = (IEnumerable<SelectListItem>)Session["Processor"];
                    model.addFinance = new AddFinanceModel();
                    model.addFinance.activityType = (IEnumerable<SelectListItem>)Session["ActivityType"];
                    model.addFinance.processorCompany = (IEnumerable<SelectListItem>)Session["Processor"];
                    return View(model);
            }
            return View();
        }
Exemplo n.º 4
0
 public PartialViewResult SearchGrid()
 {
     var model = new SearchFinanceModel();
     if (Session["Financemodel"] != null)
     {
         model = (SearchFinanceModel)Session["Financemodel"];
     }
     return (PartialView("_SearchGrid", model));
 }
Exemplo n.º 5
0
 public ActionResult Index()
 {
     var model = new SearchFinanceModel();
     Session["Financemodel"] = null;
     model.activityType = GetActivityType();
     model.processorCompany = GetProcessorNames();
     model.addFinance = new AddFinanceModel();
     model.addFinance.activityType = model.activityType;
     model.addFinance.processorCompany = model.processorCompany;
     Session["ActivityType"] = model.activityType;
     Session["Processor"] = model.processorCompany;
     ViewBag.SuccessMsg = TempData["SuccessMsg"];
     return View(model);
 }