public organization Get(int id) { using (Count10_DevEntities entities = new Count10_DevEntities()) { return(entities.organizations.FirstOrDefault(e => e.id == id)); } }
public IHttpActionResult post([FromBody] organization organizations) { try { if (string.IsNullOrEmpty(organizations.name)) { ModelState.AddModelError("name", "Name is Required"); } if (ModelState.IsValid) { using (Count10_DevEntities entities = new Count10_DevEntities()) { organizations.active = organizations.active.HasValue ? organizations.active : true; organizations.archived = organizations.archived.HasValue ? organizations.archived : false; organizations.updated_by = organizations.updated_by.HasValue ? organizations.updated_by : 1; organizations.created_by = organizations.created_by.HasValue ? organizations.created_by : 1; organizations.created_at = DateTime.Now; organizations.updated_at = DateTime.Now; entities.organizations.Add(organizations); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, organizations); } return(Ok(organizations)); } return(BadRequest(ModelState)); } catch (Exception) { return(BadRequest(ModelState)); } }
public HttpResponseMessage put(int id, [FromBody] organization organizations) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.organizations.FirstOrDefault(e => e.id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Organization with Id = " + id.ToString() + " not found to edit")); } else { entity.name = organizations.name; entity.alt_name = organizations.alt_name; entity.parent_id = organizations.parent_id; entity.notes = organizations.notes; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage put(int id, [FromBody] currency currencies) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.currencies.FirstOrDefault(e => e.id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Currency with Id = " + id.ToString() + " not found to edit")); } else { entity.name = currencies.name; entity.alt_name = currencies.alt_name; entity.iso_code = currencies.iso_code; entity.iso_number = currencies.iso_number; entity.fractionals = currencies.fractionals; entity.fractionals_name = currencies.fractionals_name; entity.display_name = currencies.display_name; entity.placement = currencies.placement; entity.notes = currencies.notes; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public currency Get(int id) { using (Count10_DevEntities entities = new Count10_DevEntities()) { return(entities.currencies.FirstOrDefault(e => e.id == id)); } }
public IHttpActionResult post([FromBody] chart_of_accounts chartOfAccounts) { try { if (string.IsNullOrEmpty(chartOfAccounts.name)) { ModelState.AddModelError("name", "Name is Required"); } if (ModelState.IsValid) { using (Count10_DevEntities entities = new Count10_DevEntities()) { chartOfAccounts.system = chartOfAccounts.system.HasValue ? chartOfAccounts.system : false; chartOfAccounts.reserved = chartOfAccounts.reserved.HasValue ? chartOfAccounts.reserved : false; chartOfAccounts.active = chartOfAccounts.active.HasValue ? chartOfAccounts.active : true; chartOfAccounts.archived = chartOfAccounts.archived.HasValue ? chartOfAccounts.archived : false; chartOfAccounts.created_by = chartOfAccounts.created_by.HasValue ? chartOfAccounts.created_by : 1; chartOfAccounts.updated_by = chartOfAccounts.updated_by.HasValue ? chartOfAccounts.updated_by : 1; chartOfAccounts.created_at = DateTime.Now; chartOfAccounts.updated_at = DateTime.Now; entities.chart_of_accounts.Add(chartOfAccounts); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, chartOfAccounts); } return(Ok(chartOfAccounts)); } return(BadRequest(ModelState)); } catch (Exception) { return(BadRequest(ModelState)); } }
public item Get(int id) { using (Count10_DevEntities entities = new Count10_DevEntities()) { return(entities.items.FirstOrDefault(e => e.id == id)); } }
public chart_of_accounts Get(int id) { using (Count10_DevEntities entities = new Count10_DevEntities()) { return(entities.chart_of_accounts.FirstOrDefault(e => e.id == id)); } }
public HttpResponseMessage put(int id, [FromBody] chart_of_accounts chartOfAccounts) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.chart_of_accounts.FirstOrDefault(e => e.id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Chart of Account with Id = " + id.ToString() + " not found to edit")); } else { entity.name = chartOfAccounts.name; entity.alt_name = chartOfAccounts.alt_name; entity.predefined_name = chartOfAccounts.predefined_name; entity.parent_id = chartOfAccounts.parent_id; entity.nature_id = chartOfAccounts.nature_id; entity.organization_id = chartOfAccounts.organization_id; entity.blsl = chartOfAccounts.blsl; entity.position = chartOfAccounts.position; entity.tag = chartOfAccounts.tag; entity.notes = chartOfAccounts.notes; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Get(string listData = "") { using (Count10_DevEntities entities = new Count10_DevEntities()) { switch (listData.ToLower().ToString()) { case "all": return(Request.CreateResponse(HttpStatusCode.OK, entities.organizations.ToList())); default: return(Request.CreateResponse(HttpStatusCode.OK, entities.organizations.Where(e => e.id > 0).ToList())); } } }
public HttpResponseMessage Get(string listData = "") { using (Count10_DevEntities entities = new Count10_DevEntities()) { switch (listData.ToLower().ToString()) { case "all": return(Request.CreateResponse(HttpStatusCode.OK, entities.chart_of_accounts.Where(e => e.reserved == false).ToList())); default: return(Request.CreateResponse(HttpStatusCode.OK, entities.chart_of_accounts.Where(e => e.id > 0 && e.reserved == false).ToList())); } } }
public HttpResponseMessage put(int id, [FromBody] location locations) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.locations.FirstOrDefault(e => e.id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "location with Id = " + id.ToString() + " not found to edit")); } else { entity.name = locations.name; entity.alt_name = locations.alt_name; entity.region_id = locations.region_id; entity.organization_id = locations.organization_id; entity.currency_id = locations.currency_id; entity.stock_ledger_id = locations.stock_ledger_id; entity.manager_id = locations.manager_id; entity.kind = locations.kind; entity.@virtual = locations.@virtual; entity.inventoriable = locations.inventoriable; entity.grade = locations.grade; entity.format = locations.format; entity.area = locations.area; entity.activity_area = locations.activity_area; entity.latitude = locations.latitude; entity.longitude = locations.longitude; entity.notes = locations.notes; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Delete(int id) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.organizations.FirstOrDefault(e => e.id == id); if (entities == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Organization with Id = " + id.ToString() + " not found to delete")); } else { entities.organizations.Remove(entity); entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage put(int id, [FromBody] ledger ledgers) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.ledgers.FirstOrDefault(e => e.id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Ledger with Id = " + id.ToString() + " not found to edit")); } else { entity.name = ledgers.name; entity.alt_name = ledgers.alt_name; entity.parent_id = ledgers.parent_id; entity.chart_of_account_id = ledgers.chart_of_account_id; entity.organization_id = ledgers.organization_id; entity.cost_centre_id = ledgers.cost_centre_id; entity.currency_id = ledgers.currency_id; entity.position = ledgers.position; entity.opening_balance = ledgers.opening_balance; entity.opening_cr_dr = ledgers.opening_cr_dr; entity.current_balance = ledgers.current_balance; entity.current_cr_dr = ledgers.current_cr_dr; entity.notes = ledgers.notes; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }