public ActionResult AddOrEdit(MVCAccountTableModel mvcAccountModel)
        {
            try
            {
                mvcAccountModel.FK_CompanyId = Convert.ToInt32(Session["CompayID"]);
                mvcAccountModel.AddedBy      = 1;
                if (mvcAccountModel.AccountId == null || mvcAccountModel.AccountId == 0)
                {
                    HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("PostAccount", mvcAccountModel).Result;

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        return(Json(response.StatusCode, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    HttpResponseMessage response = GlobalVeriables.WebApiClient.PutAsJsonAsync("UpdateAccount/" + mvcAccountModel.AccountId, mvcAccountModel).Result;

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        return(Json(response.StatusCode, JsonRequestBehavior.AllowGet));
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public IHttpActionResult GetHeadAccountByID(int ACid, int companyId)
        {
            if (ACid > 0)
            {
                try
                {
                    MVCAccountTableModel AccountObj = db.AccountTables.Where(x => x.FK_CompanyId == companyId && x.AccountId == ACid).Select(c => new MVCAccountTableModel
                    {
                        AccountId          = c.AccountId,
                        AccountTitle       = c.AccountTitle,
                        AccountDescription = c.AccountDescription,
                        FK_HeadAccountId   = c.FK_HeadAccountId,
                        AccountCode        = c.AccountCode
                    }).FirstOrDefault();

                    return(Ok(AccountObj));
                }
                catch (Exception)
                {
                    return(NotFound());
                }
            }
            else
            {
                return(NotFound());
            }
        }
        public ActionResult CheckAccountAvailibility(string Name, int HdAcountId)
        {
            MVCAccountTableModel mvcAccountModel = new MVCAccountTableModel();

            mvcAccountModel.FK_CompanyId     = Convert.ToInt32(Session["CompayID"]);
            mvcAccountModel.FK_HeadAccountId = HdAcountId;
            mvcAccountModel.AccountTitle     = Name;
            HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("AccountTitle", mvcAccountModel).Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(Json("Found", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("NotFound", JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult GetAccountByID(int AccountID = 0)
        {
            if (AccountID > 0)
            {
                int companyid = Convert.ToInt32(Session["CompayID"]);


                HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("AccountByID/" + AccountID + "/" + companyid).Result;


                MVCAccountTableModel AccountmodelObj = response.Content.ReadAsAsync <MVCAccountTableModel>().Result;

                return(Json(AccountmodelObj, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Null", JsonRequestBehavior.AllowGet));
            }
        }