public int PostSymbol(Models.SectorSymbol Value) { try { var Symbol = from d in db.MstSymbols where d.Symbol == Value.Symbol select d; if (Symbol.Any()) { Data.TrnSectorSymbol NewSectorSymbol = new Data.TrnSectorSymbol(); NewSectorSymbol.SectorId = Value.SectorId; NewSectorSymbol.SymbolId = Symbol.First().Id; NewSectorSymbol.Symbol = Symbol.First().Symbol; db.TrnSectorSymbols.InsertOnSubmit(NewSectorSymbol); db.SubmitChanges(); return(NewSectorSymbol.Id); } else { return(0); } } catch { return(0); } }
public HttpResponseMessage DeleteSymbol(int Id) { Data.TrnSectorSymbol DeleteSectorSymbol = db.TrnSectorSymbols.Where(d => d.Id == Id).First(); if (DeleteSectorSymbol != null) { db.TrnSectorSymbols.DeleteOnSubmit(DeleteSectorSymbol); try { db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } }