public HttpResponseMessage GetDrivers() { List <Data.vendor> vendor = repo.GetAll().ToList(); List <VendorBO> vendorList = new List <VendorBO>(); if (vendor.Count > 0) { foreach (var driv in vendor) { VendorBO vendorBO = new VendorBO(); vendorBO.vendid = driv.vendid; vendorBO.vendkey = driv.vendkey; vendorBO.vendname = driv.vendname; vendorBO.status = driv.status; vendorBO.statusdate = driv.statusdate; var address = new AddressRepository().GetbyId(driv.addrkey); if (address != null) { vendorBO.Address = new AddressBO() { AddrKey = address.addrkey, Address1 = address.address1, Address2 = address.address2, City = address.city, State = address.state, Zip = address.zipcode, Email = address.email, Phone = address.phone, Fax = address.fax }; } vendorList.Add(vendorBO); } return(Request.CreateResponse(HttpStatusCode.OK, vendorList, Configuration.Formatters.JsonFormatter)); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Not found", Configuration.Formatters.JsonFormatter)); } }
public HttpResponseMessage Post([FromBody] VendorBO vendorBO) { Data.vendor _vendor = new Data.vendor(); _vendor.vendid = vendorBO.vendid; _vendor.vendname = vendorBO.vendname; _vendor.status = 1; _vendor.statusdate = DateTime.Now; if (vendorBO.Address != null) { var custaddress = new Data.address() { addrkey = vendorBO.Address.AddrKey, address1 = vendorBO.Address.Address1, address2 = vendorBO.Address.Address2, city = vendorBO.Address.City, state = vendorBO.Address.State, country = vendorBO.Address.Country, zipcode = vendorBO.Address.Zip, email = vendorBO.Address.Email, fax = vendorBO.Address.Fax, phone = vendorBO.Address.Phone, website = vendorBO.Address.Website, addrname = _vendor.vendid }; var addrkey = new AddressRepository().Add(custaddress); _vendor.addrkey = addrkey; } Guid custId = repo.Add(_vendor); if (custId != null && custId != Guid.Empty) { return(Request.CreateResponse(HttpStatusCode.OK, custId, Configuration.Formatters.JsonFormatter)); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Put([FromBody] VendorBO vendorBO) { Data.vendor _vendor = new Data.vendor(); _vendor.vendkey = vendorBO.vendkey; _vendor.vendid = vendorBO.vendid; _vendor.vendname = vendorBO.vendname; _vendor.status = 1; _vendor.statusdate = DateTime.Now; if (vendorBO.Address != null) { var custaddress = new Data.address() { addrkey = vendorBO.Address.AddrKey, address1 = vendorBO.Address.Address1, address2 = vendorBO.Address.Address2, city = vendorBO.Address.City, state = vendorBO.Address.State, country = vendorBO.Address.Country, zipcode = vendorBO.Address.Zip, email = vendorBO.Address.Email, fax = vendorBO.Address.Fax, phone = vendorBO.Address.Phone, website = vendorBO.Address.Website, addrname = _vendor.vendname }; bool updated = new AddressRepository().Update(custaddress); } bool result = repo.Update(_vendor); if (result) { return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage GetDriverByID(string vendorkey) { Data.vendor vendor = repo.GetbyId(Guid.Parse(vendorkey)); VendorBO vendorBO = new VendorBO(); if (vendor != null) { vendorBO.vendid = vendor.vendid; vendorBO.vendkey = vendor.vendkey; vendorBO.vendname = vendor.vendname; vendorBO.status = vendor.status; vendorBO.statusdate = vendor.statusdate; var address = new AddressRepository().GetbyId(vendor.addrkey); if (address != null) { vendorBO.Address = new AddressBO() { AddrKey = address.addrkey, Address1 = address.address1, Address2 = address.address2, City = address.city, State = address.state, Zip = address.zipcode, Email = address.email, Phone = address.phone, Fax = address.fax, Website = address.website, Country = address.country }; } return(Request.CreateResponse(HttpStatusCode.OK, vendorBO, Configuration.Formatters.JsonFormatter)); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Not found", Configuration.Formatters.JsonFormatter)); } }
/// <summary> /// To Update details of Vendor in tbl_Vendor_M table /// Created By : Chintan, 10/28/2014 /// Modified By : /// </summary> /// <param name="objVendorBO"></param> /// <returns></returns> public ApplicationResult Vendor_Update(VendorBO objVendorBO) { try { pSqlParameter = new SqlParameter[22]; pSqlParameter[0] = new SqlParameter("@VendorID", SqlDbType.Int); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objVendorBO.VendorID; pSqlParameter[1] = new SqlParameter("@TrustMID", SqlDbType.Int); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objVendorBO.TrustMID; pSqlParameter[2] = new SqlParameter("@SchoolMID", SqlDbType.Int); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objVendorBO.SchoolMID; pSqlParameter[3] = new SqlParameter("@VendorName", SqlDbType.VarChar); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objVendorBO.VendorName; pSqlParameter[4] = new SqlParameter("@Address", SqlDbType.VarChar); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objVendorBO.Address; pSqlParameter[5] = new SqlParameter("@TelephoneNo", SqlDbType.VarChar); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objVendorBO.TelephoneNo; pSqlParameter[6] = new SqlParameter("@MobileNo", SqlDbType.VarChar); pSqlParameter[6].Direction = ParameterDirection.Input; pSqlParameter[6].Value = objVendorBO.MobileNo; pSqlParameter[7] = new SqlParameter("@Fax", SqlDbType.VarChar); pSqlParameter[7].Direction = ParameterDirection.Input; pSqlParameter[7].Value = objVendorBO.Fax; pSqlParameter[8] = new SqlParameter("@EmailID", SqlDbType.VarChar); pSqlParameter[8].Direction = ParameterDirection.Input; pSqlParameter[8].Value = objVendorBO.EmailID; pSqlParameter[9] = new SqlParameter("@TINGST", SqlDbType.VarChar); pSqlParameter[9].Direction = ParameterDirection.Input; pSqlParameter[9].Value = objVendorBO.TINGST; pSqlParameter[10] = new SqlParameter("@TINCST", SqlDbType.VarChar); pSqlParameter[10].Direction = ParameterDirection.Input; pSqlParameter[10].Value = objVendorBO.TINCST; pSqlParameter[11] = new SqlParameter("@BankName", SqlDbType.VarChar); pSqlParameter[11].Direction = ParameterDirection.Input; pSqlParameter[11].Value = objVendorBO.BankName; pSqlParameter[12] = new SqlParameter("@AccountNo", SqlDbType.VarChar); pSqlParameter[12].Direction = ParameterDirection.Input; pSqlParameter[12].Value = objVendorBO.AccountNo; pSqlParameter[13] = new SqlParameter("@AccountName", SqlDbType.VarChar); pSqlParameter[13].Direction = ParameterDirection.Input; pSqlParameter[13].Value = objVendorBO.AccountName; pSqlParameter[14] = new SqlParameter("@IFSCCode", SqlDbType.VarChar); pSqlParameter[14].Direction = ParameterDirection.Input; pSqlParameter[14].Value = objVendorBO.IFSCCode; pSqlParameter[15] = new SqlParameter("@PANNO", SqlDbType.VarChar); pSqlParameter[15].Direction = ParameterDirection.Input; pSqlParameter[15].Value = objVendorBO.PANNO; pSqlParameter[16] = new SqlParameter("@TaxRegNo", SqlDbType.VarChar); pSqlParameter[16].Direction = ParameterDirection.Input; pSqlParameter[16].Value = objVendorBO.TaxRegNo; pSqlParameter[17] = new SqlParameter("@IsDeleted", SqlDbType.Int); pSqlParameter[17].Direction = ParameterDirection.Input; pSqlParameter[17].Value = objVendorBO.IsDeleted; pSqlParameter[18] = new SqlParameter("@CreatedDate", SqlDbType.VarChar); pSqlParameter[18].Direction = ParameterDirection.Input; pSqlParameter[18].Value = objVendorBO.CreatedDate; pSqlParameter[19] = new SqlParameter("@CreatedUserID", SqlDbType.Int); pSqlParameter[19].Direction = ParameterDirection.Input; pSqlParameter[19].Value = objVendorBO.CreatedUserID; pSqlParameter[20] = new SqlParameter("@LastModifiedDate", SqlDbType.VarChar); pSqlParameter[20].Direction = ParameterDirection.Input; pSqlParameter[20].Value = objVendorBO.LastModifiedDate; pSqlParameter[21] = new SqlParameter("@LastModifiedUserID", SqlDbType.Int); pSqlParameter[21].Direction = ParameterDirection.Input; pSqlParameter[21].Value = objVendorBO.LastModifiedUserID; sSql = "usp_tbl_Vendor_M_Update"; int iResult = Database.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter); if (iResult > 0) { ApplicationResult objResults = new ApplicationResult(); objResults.status = ApplicationResult.CommonStatusType.SUCCESS; return(objResults); } else { ApplicationResult objResults = new ApplicationResult(); objResults.status = ApplicationResult.CommonStatusType.FAILURE; return(objResults); } } catch (Exception ex) { throw ex; } finally { objVendorBO = null; } }
protected void btnSave_Click(object sender, EventArgs e) { try { ApplicationResult objResults = new ApplicationResult(); VendorBO objVendorBO = new VendorBO(); VendorBL objVendorBL = new VendorBL(); objVendorBO.VendorName = txtVendorName.Text; objVendorBO.Address = txtAddress.Text; objVendorBO.TelephoneNo = txtTelephoneNo.Text; objVendorBO.MobileNo = txtMobileNo.Text; objVendorBO.Fax = txtFax.Text; objVendorBO.EmailID = txtEmail.Text; objVendorBO.TINGST = txtTinGst.Text; objVendorBO.TINCST = txtTinCst.Text; objVendorBO.BankName = txtBankName.Text; objVendorBO.AccountNo = txtAccountNo.Text; objVendorBO.AccountName = txtAccountName.Text; objVendorBO.IFSCCode = txtIFSCCode.Text; objVendorBO.PANNO = txtPanNo.Text; objVendorBO.TaxRegNo = txtTaxRegNo.Text; objVendorBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objVendorBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); int intClear = 1; if (ViewState["Mode"].ToString() == "Save") { objVendorBO.CreatedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objVendorBO.CreatedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objResults = objVendorBL.Vendor_Insert(objVendorBO); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { intClear = 1; ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Vendor Created Successfully.');</script>"); } else { intClear = 0; ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Vendor is already exist.');</script>"); } } else if (ViewState["Mode"].ToString() == "Edit") { objVendorBO.VendorID = Convert.ToInt32(ViewState["VendorID"].ToString()); objResults = objVendorBL.Vendor_Update(objVendorBO); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { intClear = 1; ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Vendor updated successfully.');</script>"); } else { intClear = 0; ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Unit Name is already exist.');</script>"); } } if (intClear == 1) { ClearAll(); GridDataBind(); } else { txtVendorName.Text = ""; } } catch (Exception ex) { logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }