public string GetOtherIncomeDetails(string ID) { try { OtherIncomeViewModel otherIncomeObj = Mapper.Map <OtherIncome, OtherIncomeViewModel>(_otherIncomeBusiness.GetOtherIncomeDetails(ID != null && ID != "" ? Guid.Parse(ID) : Guid.Empty)); if (otherIncomeObj != null) { otherIncomeObj.AccountCode = otherIncomeObj.AccountCode + ":" + otherIncomeObj.chartOfAccountsObj.ISEmploy; } return(JsonConvert.SerializeObject(new { Result = "OK", Records = otherIncomeObj })); } catch (Exception ex) { AppConstMessage cm = c.GetMessage(ex.Message); return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message })); } }
public string Validate(OtherIncomeViewModel _otherincome) { AppUA _appUA = Session["AppUA"] as AppUA; object result = null; try { result = _otherIncomeBusiness.Validate(Mapper.Map <OtherIncomeViewModel, OtherIncome>(_otherincome)); return(JsonConvert.SerializeObject(new { Result = "OK", Message = "", Records = result })); } catch (Exception ex) { AppConstMessage cm = c.GetMessage(ex.Message); return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message, Status = -1 })); } }
public ActionResult Index(string id) { OtherIncomeViewModel otherIncomeViewModalObj = null; ViewBag.value = id; try { otherIncomeViewModalObj = new OtherIncomeViewModel(); otherIncomeViewModalObj.accountCodeList = new List <SelectListItem>(); Settings s = new Settings(); otherIncomeViewModalObj.Today = DateTime.Today.ToString(s.dateformat); List <SelectListItem> selectListItem = new List <SelectListItem>(); selectListItem = new List <SelectListItem>(); List <BankViewModel> PayTermList = Mapper.Map <List <Bank>, List <BankViewModel> >(_bankBusiness.GetAllBanks()); foreach (BankViewModel bvm in PayTermList) { selectListItem.Add(new SelectListItem { Text = bvm.Name, Value = bvm.Code, Selected = false }); } otherIncomeViewModalObj.bankList = selectListItem; otherIncomeViewModalObj.companiesList = new List <SelectListItem>(); selectListItem = new List <SelectListItem>(); List <CompaniesViewModel> companiesList = Mapper.Map <List <Companies>, List <CompaniesViewModel> >(_companiesBusiness.GetAllCompanies()); foreach (CompaniesViewModel cvm in companiesList) { selectListItem.Add(new SelectListItem { Text = cvm.Name, Value = cvm.Code.ToString(), Selected = false }); } otherIncomeViewModalObj.companiesList = selectListItem; otherIncomeViewModalObj.paymentModeList = new List <SelectListItem>(); selectListItem = new List <SelectListItem>(); List <PaymentModesViewModel> PaymentList = Mapper.Map <List <PaymentModes>, List <PaymentModesViewModel> >(_paymentModeBusiness.GetAllPaymentModes()); foreach (PaymentModesViewModel PMVM in PaymentList) { selectListItem.Add(new SelectListItem { Text = PMVM.Description, Value = PMVM.Code, Selected = false }); } otherIncomeViewModalObj.paymentModeList = selectListItem; otherIncomeViewModalObj.accountCodeList = new List <SelectListItem>(); selectListItem = new List <SelectListItem>(); List <ChartOfAccountsViewModel> AccountList = Mapper.Map <List <ChartOfAccounts>, List <ChartOfAccountsViewModel> >(_chartOfAccountsBusiness.GetChartOfAccountsByType("OI")); foreach (ChartOfAccountsViewModel COAVM in AccountList) { selectListItem.Add(new SelectListItem { Text = COAVM.TypeDesc, Value = COAVM.Code + ":" + COAVM.ISEmploy, Selected = false }); } otherIncomeViewModalObj.accountCodeList = selectListItem; //selectListItem = new List<SelectListItem>(); //List<EmployeeViewModel> empList = Mapper.Map<List<Employee>, List<EmployeeViewModel>>(_otherExpenseBusiness.GetAllEmployees()); //foreach (EmployeeViewModel evm in empList) //{ // selectListItem.Add(new SelectListItem // { // Text = evm.Name, // Value = evm.ID.ToString(), // Selected = false // }); //} //otherIncomeViewModalObj.EmployeeList = selectListItem; otherIncomeViewModalObj.EmployeeTypeList = new List <SelectListItem>(); selectListItem = new List <SelectListItem>(); List <EmployeeTypeViewModel> empTypeList = Mapper.Map <List <EmployeeType>, List <EmployeeTypeViewModel> >(_otherExpenseBusiness.GetAllEmployeeTypes()); foreach (EmployeeTypeViewModel etvm in empTypeList) { selectListItem.Add(new SelectListItem { Text = etvm.Name, Value = etvm.Code, Selected = false }); } otherIncomeViewModalObj.EmployeeTypeList = selectListItem; } catch (Exception ex) { throw ex; } return(View(otherIncomeViewModalObj)); }
public string InsertUpdateOtherIncome(OtherIncomeViewModel _otherIncomeObj) { //if (!ModelState.IsValid) //{ try { //removiing combined code int len = _otherIncomeObj.AccountCode.IndexOf(':'); _otherIncomeObj.AccountCode = _otherIncomeObj.AccountCode.Remove(len); // // try //{ //object result = null; AppUA _appUA = Session["AppUA"] as AppUA; _otherIncomeObj.commonObj = new CommonViewModel(); _otherIncomeObj.commonObj.CreatedBy = _appUA.UserName; _otherIncomeObj.commonObj.CreatedDate = _appUA.DateTime; _otherIncomeObj.commonObj.UpdatedBy = _appUA.UserName; _otherIncomeObj.commonObj.UpdatedDate = _appUA.DateTime; OtherIncomeViewModel otherIncomeVM = null; switch (_otherIncomeObj.ID == Guid.Empty) { //INSERT case true: otherIncomeVM = Mapper.Map <OtherIncome, OtherIncomeViewModel>(_otherIncomeBusiness.InsertOtherIncome(Mapper.Map <OtherIncomeViewModel, OtherIncome>(_otherIncomeObj))); return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherIncomeVM, Message = c.InsertSuccess })); default: //Getting UA otherIncomeVM = Mapper.Map <OtherIncome, OtherIncomeViewModel>(_otherIncomeBusiness.UpdateOtherIncome(Mapper.Map <OtherIncomeViewModel, OtherIncome>(_otherIncomeObj))); return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherIncomeVM, Message = c.UpdateSuccess })); } } //result = _otherIncomeBusiness.InsertUpdateOtherIncome(Mapper.Map<OtherIncomeViewModel, OtherIncome>(_otherIncomeObj)); //return JsonConvert.SerializeObject(new { Result = "OK", Records = result }); // } catch (Exception ex) { AppConstMessage cm = c.GetMessage(ex.Message); return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message })); } //Model state errror //else //{ // List<string> modelErrors = new List<string>(); // foreach (var modelState in ModelState.Values) // { // foreach (var modelError in modelState.Errors) // { // modelErrors.Add(modelError.ErrorMessage); // } // } // return JsonConvert.SerializeObject(new { Result = "VALIDATION", Message = string.Join(",", modelErrors) }); //} }