public IActionResult GetCompanyList() { try { var companiesList = CompaniesHelper.GetListOfCompanies(); if (companiesList.Count > 0) { dynamic expdoObj = new ExpandoObject(); expdoObj.companiesList = companiesList; return(Ok(new APIResponse { status = APIStatus.PASS.ToString(), response = expdoObj })); } else { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = "No Data Found." })); } } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
//public static BrandModel RegisterBrandModel(BrandModel brandModel) //{ // try // { // using (Repository<BrandModel> repo = new Repository<BrandModel>()) // { // var record = repo.BrandModel.OrderByDescending(x => x.AddDate).FirstOrDefault(); // if (record != null) // { // brandModel.Code = CommonHelper.IncreaseCode(record.Code); // } // else // brandModel.Code = "1"; // brandModel.Active = "Y"; // repo.BrandModel.Add(brandModel); // if (repo.SaveChanges() > 0) // return brandModel; // return null; // } // } // catch (Exception ex) // { // throw ex; // } //} //public static List<BrandModel> GetBrandModelList() //{ // try // { // using (Repository<BrandModel> repo = new Repository<BrandModel>()) // { // return repo.BrandModel.Select(x => x).ToList(); // } // } // catch { throw; } //} //public static BrandModel GetBrandModelList(string modelCode) //{ // try // { // using (Repository<BrandModel> repo = new Repository<BrandModel>()) // { // return repo.BrandModel.Where(x => x.Code == modelCode).FirstOrDefault(); // } // } // catch { throw; } //} //public static BrandModel UpdateBrandModelClass(BrandModel brandModel) //{ // try // { // using (Repository<BrandModel> repo = new Repository<BrandModel>()) // { // repo.BrandModel.Update(brandModel); // if (repo.SaveChanges() > 0) // return brandModel; // return null; // } // } // catch (Exception ex) // { // throw ex; // } //} //public static BrandModel DeleteBrandModelClass(string code) //{ // try // { // using (Repository<BrandModel> repo = new Repository<BrandModel>()) // { // var brandModel = repo.BrandModel.Where(x => x.Code == code).FirstOrDefault(); // brandModel.Active = "N"; // repo.BrandModel.Update(brandModel); // if (repo.SaveChanges() > 0) // return brandModel; // return null; // } // } // catch (Exception ex) // { // throw ex; // } //} public static List <Companies> GetCompanies() { try { return(CompaniesHelper.GetListOfCompanies()); } catch { throw; } }
public static List <Companies> GetCompanies() { try { using Repository <Purchase> repo = new Repository <Purchase>(); return(CompaniesHelper.GetListOfCompanies()); } catch { throw; } }
public IActionResult RegisterCompany([FromBody] Companies company) { if (company == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(company)} cannot be null" })); } else { if (CompaniesHelper.GetCompanies(company.CompanyCode) != null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Code =" + company.CompanyCode + " is already Exists,Please Use Another Code" })); } try { APIResponse apiResponse = null; var result = CompaniesHelper.Register(company); if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Registration Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = ex.Message })); } } }
public IActionResult GetCompanysList() { try { dynamic expando = new ExpandoObject(); expando.CompanysList = CompaniesHelper.GetListOfCompanies().Select(comp => new { ID = comp.CompanyCode, TEXT = comp.Name }); return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult UpdateCompany([FromBody] Companies company) { if (company == null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = $"{nameof(company)} cannot be null" })); } try { APIResponse apiResponse = null; Companies result = CompaniesHelper.Update(company); if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult DeleteCompany(string code) { if (code == null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = $"{nameof(code)}can not be null" })); } try { var result = CompaniesHelper.DeleteCompanies(code); APIResponse apiResponse; if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public async Task <IActionResult> GetAllCompanys() { var result = await Task.Run(() => { try { var companiesList = CompaniesHelper.GetListOfCompanies(); dynamic expdoObj = new ExpandoObject(); expdoObj.companiesList = companiesList; return(Ok(new APIResponse { status = APIStatus.PASS.ToString(), response = expdoObj })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }); return(result); }