public async Task <IActionResult> Edit(int id, AccountingAccount accountingAccount, IFormCollection form) { var accountType = form["AccountType"]; accountingAccount.AccountType = (from c in _context.AccountType where c.ID.ToString() == accountType.ToString() select c).Single(); if (id != accountingAccount.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(accountingAccount); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountingAccountExists(accountingAccount.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(accountingAccount)); }
public string SendAccounts(AccountingAccount contact, string token, int accountingSystem = 9) { using (var client = new HttpClient()) { ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // var token = await GetApiToken(); //setup client client.BaseAddress = new Uri(Url); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var apiPath = "api/v1/AccountingAccounts"; var param = Newtonsoft.Json.JsonConvert.SerializeObject(contact); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = client.PostAsync(apiPath, contentPost).Result; return(response.StatusCode.ToString()); //HttpResponseMessage postResponse = await client.GetAsync(Url.TrimEnd('/') + "/" + apiPath); //// postResponse.EnsureSuccessStatusCode(); //var postResult = await postResponse.Content.ReadAsStringAsync(); //return postResult.ToString(); //////send request ////HttpResponseMessage responseMessage = await client.PostAsync("/Token", formContent); //////get access token from response body ////var responseJson = await responseMessage.Content.ReadAsStringAsync(); ////var jObject = JObject.Parse(responseJson); ////return jObject.GetValue("access_token").ToString(); } }
public ActionResult Edit([Bind(Include = "ACC_IDE_ACCOUNT,ACC_DES_ACCOUNT,ACC_FH_CREATED")] AccountingAccount accountingAccount) { if (ModelState.IsValid) { if (_db.Update(accountingAccount)) { return(RedirectToAction("Index")); } } return(View(accountingAccount)); }
public bool Create(AccountingAccount model) { if (model != null) { using (AuthenticationDB db = new AuthenticationDB()) { db.AccountingAccounts.Add(model); return((db.SaveChanges() > 0) ? true : false); } } return(false); }
public ActionResult Create([Bind(Include = "ACC_IDE_ACCOUNT,ACC_DES_ACCOUNT")] AccountingAccount accountingAccount) { if (ModelState.IsValid) { accountingAccount.ACC_FH_CREATED = DateTime.Now; if (_db.Create(accountingAccount)) { return(RedirectToAction("Index")); } } return(View(accountingAccount)); }
public Boolean Update(AccountingAccount accountingAccount) { if (accountingAccount != null) { using (AuthenticationDB db = new AuthenticationDB()) { db.AccountingAccounts.Attach(accountingAccount); db.Entry(accountingAccount).Property(ob => ob.ACC_DES_ACCOUNT).IsModified = true; return((db.SaveChanges() > 0) ? true : false); } } return(false); }
// GET: AccountingAccounts/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AccountingAccount accountingAccount = _db.GetOne(id); if (accountingAccount == null) { return(HttpNotFound()); } return(View(accountingAccount)); }
public AccountingAccount GetOne(string id) { if (id != null) { using (AuthenticationDB db = new AuthenticationDB()) { AccountingAccount accountingAccount = db.AccountingAccounts.Find(id); if (accountingAccount != null) { return(accountingAccount); } } } return(null); }
public async Task <IActionResult> Create(AccountingAccount accountingAccount, IFormCollection form) { var accountType = form["AccountType"]; accountingAccount.AccountType = (from c in _context.AccountType where c.ID.ToString() == accountType.ToString() select c).Single(); if (ModelState.IsValid) { _context.Add(accountingAccount); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(accountingAccount)); }
public Boolean Delete(string id) { if (id != null) { AccountingAccount accountingAccount = GetOne(id); if (accountingAccount != null) { using (AuthenticationDB db = new AuthenticationDB()) { db.AccountingAccounts.Attach(accountingAccount); //db.AccountingAccounts.DeleteObject(accountingAccount); db.Entry(accountingAccount).State = System.Data.Entity.EntityState.Deleted; return((db.SaveChanges() > 0) ? true : false); } } } return(false); }