In this article, we will learn how to update an employee in Quickbooks online from .NET MVC web application using SDK.
Before using any Quickbooks online API we need access token, if you don’t know how to get access token then you can find it here.
public ActionResult UpdateEmployee() { try { OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_token); // Create a ServiceContext with Auth tokens and realmId ServiceContext serviceContext = new ServiceContext(RealmId, IntuitServicesType.QBO, oauthValidator); serviceContext.IppConfiguration.MinorVersion.Qbo = "23"; serviceContext.IppConfiguration.BaseUrl.Qbo = QboBaseUrl; string EXISTING_EMPLOYEE_QUERYBYID = string.Format("select * from Employee where id = '{0}'", "59"); var queryService = new QueryService<Employee>(serviceContext); Employee ObjEmployeeFound = queryService.ExecuteIdsQuery(EXISTING_EMPLOYEE_QUERYBYID).FirstOrDefault<Employee>(); if (ObjEmployeeFound != null) { Employee ObjEmployee = new Employee(); ObjEmployee.Id = ObjEmployeeFound.Id; ObjEmployee.SyncToken = ObjEmployeeFound.SyncToken; ObjEmployee.GivenName = ObjEmployeeFound.GivenName; ObjEmployee.FamilyName = "EmployeeEmployee"; ObjEmployee.CompanyName = ObjEmployeeFound.CompanyName; EmailAddress ObjEmail = new EmailAddress(); ObjEmail.Address = "tabish.Employee@test.com"; ObjEmployee.PrimaryEmailAddr = ObjEmail; PhysicalAddress ObjAddress = new PhysicalAddress(); ObjAddress.PostalCode = ObjEmployeeFound.PrimaryAddr.PostalCode; ObjAddress.Country = ObjEmployeeFound.PrimaryAddr.Country; ObjAddress.Line1 = ObjEmployeeFound.PrimaryAddr.Line1; ObjAddress.City = ObjEmployeeFound.PrimaryAddr.City; ObjEmployee.PrimaryAddr = ObjAddress; TelephoneNumber ObjTelephoneNumber = new TelephoneNumber(); ObjTelephoneNumber.FreeFormNumber = ObjEmployeeFound.PrimaryPhone.FreeFormNumber; ObjEmployee.PrimaryPhone = ObjTelephoneNumber; DataService dataService = new DataService(serviceContext); Employee UpdateEntity = dataService.Update<Employee>(ObjEmployee); if (UpdateEntity != null && !string.IsNullOrEmpty(UpdateEntity.Id)) { ViewBag.IsSuccess = true; } } return View(); } catch (IdsException ex) { return View(); } catch (Exception ex) { return View(); } }
@{ ViewBag.Title = "UpdateEmployee"; } <h2>Update Employee</h2> @if (ViewBag.IsSuccess != null && ViewBag.IsSuccess == true) { <div> <label class="label label-success">Employee Updated Successfully</label> </div> }
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular