public HttpResponseMessage GetUser(int id) { //User user = db.Users.Find(id); //if (user == null) //{ // return (HttpResponseMessage)Request.CreateResponse(HttpStatusCode.NotFound, new { data = string.Empty, success = false, error = string.Empty }); //} var Users = 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() where User.Id == id 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 = new { Users }, success = true, error = string.Empty })); }
// 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 })); } }
// GET: api/CropMaterial_AudioAllocation //public IQueryable<CropMaterial_AudioAllocation> GetCropMaterial_AudioAllocation() //{ // return db.CropMaterial_AudioAllocation; //} public HttpResponseMessage GetCropMaterial_Audio(int MaterialId) { var AudioAllocation = from Audiodata in db.CropMaterial_AudioAllocation join Lang in db.Languages on Audiodata.LangId equals Lang.Id into LangNew from Lang in LangNew.DefaultIfEmpty() join Audio in db.Audios on Audiodata.AudioId equals Audio.Id into AudioNew from Audio in AudioNew.DefaultIfEmpty() where Audiodata.MaterialId == MaterialId select new { Audiodata.Id, Audiodata.MaterialId, Audiodata.LangId, Lang.LanguageName, Audiodata.FieldType, Audiodata.AudioId, Audio.FileName, Audio.FilePath, Audiodata.Active }; return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { AudioAllocation }, success = true, error = string.Empty })); }
// GET: api/CropStep_VideoAllocation //public IQueryable<CropStep_VideoAllocation> GetCropStep_VideoAllocation() //{ // return db.CropStep_VideoAllocation; //} public HttpResponseMessage GetCropStep_VideoAllocation(int StepId) { var VideoAllocation = from Videodata in db.CropStep_VideoAllocation join Lang in db.Languages on Videodata.LangId equals Lang.Id into LangNew from Lang in LangNew.DefaultIfEmpty() join Video in db.Videos on Videodata.VideoId equals Video.Id into VideoNew from Video in VideoNew.DefaultIfEmpty() where Videodata.StepId == StepId && Videodata.Active == true select new { Videodata.Id, Videodata.StepId, Videodata.LangId, Lang.LanguageName, Videodata.VideoId, Video.VideoName, Video.FilePath, Videodata.Active }; return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { VideoAllocation }, success = true, error = string.Empty })); }