public HttpResponseMessage PostState(State state) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } try { var DataFound = (from statedata in db.States where statedata.StateName.ToUpper() == state.StateName.ToUpper() select statedata.StateName).SingleOrDefault(); if (DataFound == null) { db.States.Add(state); db.SaveChanges(); } else { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { string.Empty }, success = false, error = "State Name already exists" })); } return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = state.Id }, success = true, error = string.Empty })); } catch (Exception ex) { long ExceptionId = comObj.SendExcepToDB(ex); Tbl_ExceptionLogging tbl_ExceptionLogging = db.Tbl_ExceptionLogging.Find(ExceptionId); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { tbl_ExceptionLogging }, success = false, error = string.Empty })); //ExceptionLogging.SendExcepToDB(ex); //Label1.Text = "Some Technical Error occurred,Please visit after some time"; } }
public IHttpActionResult PutTbl_ExceptionLogging(long id, Tbl_ExceptionLogging tbl_ExceptionLogging) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_ExceptionLogging.Logid) { return(BadRequest()); } db.Entry(tbl_ExceptionLogging).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Tbl_ExceptionLoggingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public long SaveTbl_ExceptionLogging(Tbl_ExceptionLogging tbl_ExceptionLogging) { db.Tbl_ExceptionLogging.Add(tbl_ExceptionLogging); db.SaveChanges(); return(tbl_ExceptionLogging.Logid); }
// GET: api/Users //public IQueryable<User> GetUsers() //{ // return db.Users; //} // GET: api/Users public HttpResponseMessage GetAllUsers() { try { //int value = 1 / int.Parse("0"); var result = from User in db.Users join Gender in db.Genders on User.Gender equals Gender.Id into GenderNew from Gender in GenderNew.DefaultIfEmpty() join State in db.States on User.State equals State.Id into StateNew from State in StateNew.DefaultIfEmpty() join Role in db.Roles on User.Role equals Role.Id into RoleNew from Role in RoleNew.DefaultIfEmpty() join Lang in db.Languages on User.Language equals Lang.Id into LangNew from Lang in LangNew.DefaultIfEmpty() join District in db.Districts on User.District equals District.Id into DistrictNew from District in DistrictNew.DefaultIfEmpty() join Village in db.Villages on User.Village equals Village.Id into VillageNew from Village in VillageNew.DefaultIfEmpty() join Grampanchayat in db.Grampanchayats on User.Grampanchayat equals Grampanchayat.Id into GrampanchayatNew from Grampanchayat in GrampanchayatNew.DefaultIfEmpty() select new { User.Id, User.UserId, User.Name, User.PhoneNumber, User.Age, User.Gender, Gender.GenderName, User.State, State.StateName, User.District, District.DistrictName, User.Village, Village.VillageName, User.Grampanchayat, Grampanchayat.GrampanchayatName, User.Aadhaar, User.Role, Role.RoleName, User.Language, Lang.LanguageName, User.IMEI1, User.IMEI2, User.FCMToken, User.Active, User.ImagePath }; return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = result, success = true, error = string.Empty })); } catch (Exception ex) { long ExceptionId = comObj.SendExcepToDB(ex); Tbl_ExceptionLogging tbl_ExceptionLogging = db.Tbl_ExceptionLogging.Find(ExceptionId); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { tbl_ExceptionLogging }, success = false, error = string.Empty })); } }
public IHttpActionResult GetTbl_ExceptionLogging(long id) { Tbl_ExceptionLogging tbl_ExceptionLogging = db.Tbl_ExceptionLogging.Find(id); if (tbl_ExceptionLogging == null) { return(NotFound()); } return(Ok(tbl_ExceptionLogging)); }
public HttpResponseMessage PostTbl_ExceptionLogging(Tbl_ExceptionLogging tbl_ExceptionLogging) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } db.Tbl_ExceptionLogging.Add(tbl_ExceptionLogging); db.SaveChanges(); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = tbl_ExceptionLogging.Logid }, success = true, error = string.Empty })); }
public IHttpActionResult DeleteTbl_ExceptionLogging(long id) { Tbl_ExceptionLogging tbl_ExceptionLogging = db.Tbl_ExceptionLogging.Find(id); if (tbl_ExceptionLogging == null) { return(NotFound()); } db.Tbl_ExceptionLogging.Remove(tbl_ExceptionLogging); db.SaveChanges(); return(Ok(tbl_ExceptionLogging)); }