public ActionResult Delete(int ID) { try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.DeleteAsync("api/JobDocuments/delete/" + ID); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(RedirectToAction("Index", "Jobs")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
//string Baseurl = "http://localhost:57225/"; public ActionResult Index() { try { List <ClientModel> obj = new List <ClientModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("api/client/get"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <ClientModel> >(response); ViewBag.StatusList = new SelectList(obj[0].statusType, "ID", "name"); } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
//string Baseurl = "http://localhost:50087/"; public ActionResult Index() { try { List <JobAssignmentModel> obj = new List <JobAssignmentModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("api/JobAssignment/get"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
//string Baseurl = "http://localhost:57225/"; public ActionResult Index(int roleId = 0) { try { List <MenuRolesRelationModel> obj = new List <MenuRolesRelationModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("api/MenuRolesRelation/get/" + roleId); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <MenuRolesRelationModel> >(response); } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public ActionResult GetSubContractorSkillSets(int subcontractorID) { try { List <MembersSkillSetMappingModel> obj = new List <MembersSkillSetMappingModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("api/SubContractor/GetSubContractor/" + subcontractorID); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <MembersSkillSetMappingModel> >(response); } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public ActionResult Update(JobDocumentsModel cm) { try { List <JobDocumentsModel> JobDocumentsInfo = new List <JobDocumentsModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.PutAsJsonAsync("api/JobDocuments/update", cm); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var JobDocumentsResponse = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Sub SORType list JobDocumentsInfo = JsonConvert.DeserializeObject <List <JobDocumentsModel> >(JobDocumentsResponse); } } return(RedirectToAction("Index", "Jobs")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public List <SubSORTypeModel> GetSubSORType(int SORTypeId) { try { List <SubSORTypeModel> obj = new List <SubSORTypeModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("api/subsortype/GetSpecificSubSORType/" + SORTypeId); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <SubSORTypeModel> >(response); } } return(obj); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public async Task <ActionResult> Insert(ProjectMembersModel pm) { try { ProjectMembersModel ProjectMembersInfo = new ProjectMembersModel(); List <ProjectMembersModel> projectMembers = new List <ProjectMembersModel>(); var memSelect = Request.Form["memberSelect"].Split(','); foreach (var item in memSelect) { projectMembers.Add(new ProjectMembersModel { projId = pm.projId, memberId = Convert.ToInt32(item) }); } foreach (ProjectMembersModel p in projectMembers) { using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); p.statusId = 1; client.DefaultRequestHeaders.Clear(); var obj = JsonConvert.SerializeObject(p); // Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllComapnies using HttpClient HttpResponseMessage Res = await client.PostAsync("api/ProjectMembers/insert", new StringContent(obj, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var ProjectMembersResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Company list ProjectMembersInfo = JsonConvert.DeserializeObject <ProjectMembersModel>(ProjectMembersResponse); } //returning the company list to view } } return(RedirectToAction("Index", "Project")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public async Task <ActionResult> Insert(List <int> MenuSelect, int rId) { try { List <MenuRolesRelationModel> roleModel = new List <MenuRolesRelationModel>(); // var sSelect = Request.Form["MenuSelect"].Split(','); foreach (var item in MenuSelect) { roleModel.Add(new MenuRolesRelationModel { Id = 0, menuId = Convert.ToInt32(item), roleId = rId }); } MenuRolesRelationModel MenuRolesRelationInfo = new MenuRolesRelationModel(); using (var client = new HttpClient()) { foreach (MenuRolesRelationModel cm in roleModel) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); var obj = JsonConvert.SerializeObject(cm); // Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllComapnies using HttpClient HttpResponseMessage Res = await client.PostAsync("api/MenuRolesRelation/insert", new StringContent(obj, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var MenuRolesRelationResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Company list MenuRolesRelationInfo = JsonConvert.DeserializeObject <MenuRolesRelationModel>(MenuRolesRelationResponse); } } //returning the company list to view return(RedirectToAction("Index", "Roles")); } } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
//string Baseurl = "http://localhost:57225/"; public ActionResult Index() { try { List <AccountModel> obj = new List <AccountModel>(); using (var User = new HttpClient()) { User.BaseAddress = new Uri(Baseurl); //HTTP GET int id = 0; int roleId = 1; if (Session["acct"] != null) { if (((AccountModel)Session["acct"]).roles == "Administrator") { id = 0; roleId = 1; } else { id = ((AccountModel)Session["acct"]).Id; roleId = ((AccountModel)Session["acct"]).roleId; } } var responseTask = User.GetAsync("api/User/get/" + id + "/" + roleId); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <AccountModel> >(response); ViewBag.StatusList = new SelectList(obj[0].statusTypeList, "ID", "name"); ViewBag.MembersList = new SelectList(obj[0].membersList, "ID", "firstName"); ViewBag.SubContractorList = new SelectList(obj[0].scList, "ID", "subconName"); ViewBag.RolesList = new SelectList(obj[0].rolesList, "Id", "rolesName"); } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public ActionResult GetMembersSkillSets(int ID) { try { List <MembersSkillSetMappingModel> obj = new List <MembersSkillSetMappingModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); string tableName = "tblMembers"; string fieldName = "memberId"; var responseTask1 = client.GetAsync("api/Global/CheckDataIntegrity/" + tableName + "/" + fieldName + "/" + ID); responseTask1.Wait(); var result1 = responseTask1.Result; if (result1.IsSuccessStatusCode) { var statusTypeResponse = result1.Content.ReadAsStringAsync().Result; if (Convert.ToInt32(statusTypeResponse) == 0) { //HTTP GET var responseTask = client.GetAsync("api/members/GetMember/" + ID); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <MembersSkillSetMappingModel> >(response); } } else { ViewBag.Message = "Data already in use"; } } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
//string MasterURL = "http://localhost:57225/"; public ActionResult Index(int id = 0) { try { List<JobsModel> obj = new List<JobsModel>(); var masters = new HttpClient(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); masters.BaseAddress = new Uri(MasterURL); //HTTP GET var responseTask = client.GetAsync("api/Jobs/get/" + id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject<List<JobsModel>>(response); ViewBag.ProjectList = new SelectList(obj[0].project, "Id", "projName"); ViewBag.ProjId = id; ViewBag.TeamList = new SelectList(obj[0].team, "Id", "teamName"); ViewBag.SubContractorList = new SelectList(obj[0].subcontractor, "Id", "subconName"); ViewBag.JobStatusList = new SelectList(obj[0].jobstatus, "Id", "name"); ViewBag.ProjectJobTypeList = new SelectList(obj[0].projectjobtypes, "Id", "description"); ViewBag.ProjectRatesList = new SelectList(obj[0].projectRates, "Id", "SORCode"); ViewBag.MemberList = new SelectList(obj[0].members, "Id", "firstName"); ViewBag.JobRatesList = new SelectList(obj[0].jobRates, "Id", "SORCode"); ArrayList resPriority = new ArrayList(); resPriority.Add("High"); resPriority.Add("Medium"); resPriority.Add("Low"); ViewBag.PriorityList = new SelectList(resPriority); } } return View(obj); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public async Task <ActionResult> Insert(SubContractorModel sc) { try { SubContractorModel SubContractorInfo = new SubContractorModel(); var sSelect = Request.Form["skillSelect"].Split(','); foreach (var item in sSelect) { sc.skillSelect.Add(new SubContractorSkillSetMappingModel { subcontractorID = 0, skillSetId = Convert.ToInt32(item) }); } using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); var obj = JsonConvert.SerializeObject(sc); // Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllComapnies using HttpClient HttpResponseMessage Res = await client.PostAsync("api/SubContractor/insert", new StringContent(obj, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var SubContractorResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Company list SubContractorInfo = JsonConvert.DeserializeObject <SubContractorModel>(SubContractorResponse); } //returning the company list to view return(RedirectToAction("Index")); } } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public ActionResult Delete(int ID) { try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); string tableName = "tblRoles"; string fieldName = "roleId"; var responseTask1 = client.GetAsync("api/Global/CheckDataIntegrity/" + tableName + "/" + fieldName + "/" + ID); responseTask1.Wait(); var result1 = responseTask1.Result; if (result1.IsSuccessStatusCode) { var RolesResponse = result1.Content.ReadAsStringAsync().Result; if (Convert.ToInt32(RolesResponse) == 0) { //HTTP GET var responseTask = client.DeleteAsync("api/Roles/delete/" + ID); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } else { ViewBag.Message = "Data already in use"; } } } } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } return(RedirectToAction("Index")); }
public ActionResult Delete(int ID) { try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); string tableName = "tblProject"; string fieldName = "projId"; string ignoreTableList = "'tblProjectRates','tblProjectMembers','tblProjectSubContractors','tblProjectJobTypes'"; var responseTask1 = client.GetAsync("api/Global/CheckDataIntegrity/" + tableName + "/" + fieldName + "/" + ID + "/" + ignoreTableList); responseTask1.Wait(); var result1 = responseTask1.Result; if (result1.IsSuccessStatusCode) { var statusTypeResponse = result1.Content.ReadAsStringAsync().Result; if (Convert.ToInt32(statusTypeResponse) == 0) { //HTTP GET var responseTask = client.DeleteAsync("api/Project/delete/" + ID); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } else { ViewBag.Message = "Data already in use"; } } } return(RedirectToAction("Index")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public async Task<ActionResult> Insert(JobsModel proj) { try { JobsModel JobsInfo = new JobsModel(); using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); var obj = JsonConvert.SerializeObject(proj); // Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllComapnies using HttpJobs HttpResponseMessage Res = await client.PostAsync("api/Jobs/insert", new StringContent(obj, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpJobs if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var JobsResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Company list JobsInfo = JsonConvert.DeserializeObject<JobsModel>(JobsResponse); } //returning the company list to view int id = proj.projId; return RedirectToAction("Index",id); } } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public async Task <ActionResult> Insert(ClientModel cm) { try { if (Session["acct"] != null) { cm.userId = ((AccountModel)Session["acct"]).uId; } ClientModel ClientInfo = new ClientModel(); using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); var obj = JsonConvert.SerializeObject(cm); // Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllComapnies using HttpClient HttpResponseMessage Res = await client.PostAsync("api/client/insert", new StringContent(obj, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var ClientResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Company list ClientInfo = JsonConvert.DeserializeObject <ClientModel>(ClientResponse); } //returning the company list to view return(RedirectToAction("Index")); } } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
//string Baseurl = "http://localhost:57225/"; public ActionResult Index(int id = 0) { try { List <ProjectModel> obj = new List <ProjectModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("api/Project/get/" + id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the SORType list obj = JsonConvert.DeserializeObject <List <ProjectModel> >(response); ViewBag.LocationList = new SelectList(obj[0].location, "ID", "name"); ViewBag.ClientList = new SelectList(obj[0].client, "Id", "clientName"); ViewBag.ClientID = id; ViewBag.SORTypeList = new SelectList(obj[0].sortype, "ID", "name"); ViewBag.SubSORTypeList = new SelectList(obj[0].subsortype, "ID", "name"); ViewBag.TeamList = new SelectList(obj[0].team, "teamID", "teamName"); ViewBag.SubContractorList = new SelectList(obj[0].subcontractor, "Id", "subconName"); ViewBag.StatusTypeList = new SelectList(obj[0].statusType, "Id", "name"); ViewBag.RatesStatusList = new SelectList(obj[0].statusType, "ID", "name"); ViewBag.MembersStatusList = new SelectList(obj[0].statusType, "ID", "name"); ViewBag.SCStatusList = new SelectList(obj[0].statusType, "ID", "name"); } } return(View(obj)); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public ActionResult Update(MembersModel members) { try { List <MembersModel> membersInfo = new List <MembersModel>(); var sSelect = Request.Form["skillSelect"].Split(','); foreach (var item in sSelect) { members.skillSelect.Add(new MembersSkillSetMappingModel { memberId = members.Id, skillSetId = Convert.ToInt32(item) }); } using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.PutAsJsonAsync("api/members/update", members); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var membersResponse = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Sub SORType list membersInfo = JsonConvert.DeserializeObject <List <MembersModel> >(membersResponse); } } return(RedirectToAction("Index")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public ActionResult Update(ClientModel cm) { try { if (Session["acct"] != null) { cm.userId = ((AccountModel)Session["acct"]).uId; } List <ClientModel> ClientInfo = new List <ClientModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.PutAsJsonAsync("api/client/update", cm); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var ClientResponse = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Sub SORType list ClientInfo = JsonConvert.DeserializeObject <List <ClientModel> >(ClientResponse); } } return(RedirectToAction("Index")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public async Task <ActionResult> Login(AccountModel accountmodel) { try { if (ModelState.IsValid) { if (accountmodel.userName != null && accountmodel.password != null) { using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); //Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllEmployees using HttpClient HttpResponseMessage Res = await client.GetAsync("api/Account/Get/" + accountmodel.userName.Trim() + "/" + accountmodel.password.Trim()); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var EmpResponse = Res.Content.ReadAsStringAsync().Result; AccountModel acct = new AccountModel(); acct = JsonConvert.DeserializeObject <AccountModel>(EmpResponse); if (acct.Id > 0) { //Get Role based Menu Details HttpResponseMessage menuRes = await client.GetAsync("api/Menu/Get/" + acct.roleId + "/ G"); //Checking the response is successful or not which is sent using HttpClient if (menuRes.IsSuccessStatusCode) { var menuResponse = menuRes.Content.ReadAsStringAsync().Result; List <MenuModel> md = new List <MenuModel>(); md = JsonConvert.DeserializeObject <List <MenuModel> >(menuResponse); //Insert Records into Login Details LoginDetailsModel ld = new LoginDetailsModel(); ld.userId = acct.uId; ld.loginDate = DateTime.Now; ld.logoutDate = DateTime.Now; ld.userType = acct.userType; var ldtls = JsonConvert.SerializeObject(ld); HttpResponseMessage Res1 = await client.PostAsync("api/logindetails/insert", new StringContent(ldtls, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpClient if (Res1.IsSuccessStatusCode) { if (md.Count > 0) { FormsAuthentication.SetAuthCookie(acct.userName, false); // set the formauthentication cookie Session["acct"] = acct; // Bind the account details to "LoginCredentials" session Session["MenuDetails"] = md; //Bind the _menus list to MenuMaster session Session["UserName"] = acct.userName; return(View("Home")); } else { ModelState.AddModelError("", "User rights not assigned"); return(View("Index")); } } } } } } } ModelState.AddModelError("", "Invalid username or password"); return(View("Index")); } return(View("Index")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }