public async Task <WebApiResponse> OsztalyTorol(Osztalyok req) { InitHttpClient(); var resp = new WebApiResponse(); try { var endpoint = string.Format(baseUrlApi + "/Osztalyok/OsztalyTorol"); var json = JsonConvert.SerializeObject(req); var r = await HttpClient.PostAsync(endpoint, new StringContent(json, Encoding.UTF8, "application/json")); if (r.IsSuccessStatusCode) { var contents = await r.Content.ReadAsStringAsync(); var returnValue = JsonConvert.DeserializeObject(contents); resp = JsonConvert.DeserializeObject <WebApiResponse>(returnValue.ToString()); } else { resp.ErrorCode = ERROR_NET; resp.ErrorMessage = r.StatusCode.ToString(); } return(resp); } catch (Exception ex) { resp.ErrorCode = ERROR_GENERIC; resp.ErrorMessage = ex.ToString(); return(resp); } }
public void OsztalyTorol(Guid ID) { Osztalyok res = dbMngr.Osztalyok.Where(x => x.ID.Equals(ID)).FirstOrDefault(); if (res != null) { dbMngr.Osztalyok.Remove(res); dbMngr.SaveChanges(); } else { throw new OsztalyNemLetezikError(); } }
public void OsztalyFrissit(Guid ID, String Osztaly) { Osztalyok res = dbMngr.Osztalyok.Where(x => x.ID.Equals(ID)).FirstOrDefault(); if (res != null) { res.Osztaly = Osztaly; dbMngr.SaveChanges(); } else { throw new OsztalyNemLetezikError(); } }
public void OsztalyHozzaad(String Osztaly) { Osztalyok result = new Osztalyok(); result.ID = Guid.NewGuid(); result.Osztaly = Osztaly; if (dbMngr.Osztalyok.Where(x => x.Osztaly == result.Osztaly).FirstOrDefault() != null) { throw new Exceptions.OsztalyMarLetezikError(); } dbMngr.Osztalyok.Add(result); dbMngr.SaveChanges(); }