public async Task <HttpResponseMessage> GetAdminCampaigns(string Category = "All", int page = 1, int page_size = 500, string SortBy = "CreatedOn", string order = "Desc", string Lat = "0", string Lon = "0", int Distance = 0) { try { int CategoryId = -1; Category = string.IsNullOrEmpty(Category) ? "All" : Category; if (Category == "All") { CategoryId = -1; } else { StoryCategory cate = (StoryCategory)Enum.Parse(typeof(StoryCategory), Category); int CateId = (int)cate; CategoryId = CateId; } var res = await IService.GetAdminCampaigns_sp(CategoryId, page, page_size, SortBy, order, Lat, Lon, Distance); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (Exception ex) { ResponseObject response = new ResponseObject(); response.ExceptionMsg = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; response.ResponseMsg = "Could not get the details of campaigns"; response.ErrorCode = HttpStatusCode.InternalServerError.ToString(); return(Request.CreateResponse(HttpStatusCode.InternalServerError, response)); } }
public async Task <IActionResult> PutStoryCategory(int id, StoryCategory storyCategory) { if (id != storyCategory.CategoryID) { return(BadRequest()); } _context.Entry(storyCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoryCategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <StoryCategory> > PostStoryCategory(StoryCategory storyCategory) { _context.StoryCategory.Add(storyCategory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStoryCategory", new { id = storyCategory.CategoryID }, storyCategory)); }
public bool AddNGOModelUser(InputRegisterModel reg) { try { UserModel um = new UserModel(); var result = (from S in Entity.tbl_UserNGOEndorsement where S.UserId == reg.UserId select S).FirstOrDefault(); if (result == null) { tbl_UserNGOEndorsement NewNGO = new tbl_UserNGOEndorsement(); NewNGO.NGORegisterationNO = string.IsNullOrEmpty(reg.RegisterationNo) ? "" : reg.RegisterationNo; NewNGO.NGORegAt = string.IsNullOrEmpty(reg.Registeredat) ? "" : reg.Registeredat; if (reg.canEndorse) { if (!string.IsNullOrEmpty(reg.NGOSector)) { StoryCategory cate = (StoryCategory)Enum.Parse(typeof(StoryCategory), reg.NGOSector); int NGOSectorId = (int)cate; NewNGO.NGOSector = NGOSectorId; } if (!string.IsNullOrEmpty(reg.NGOType)) { NGOType NGOtype = (NGOType)Enum.Parse(typeof(NGOType), reg.NGOType); int NGOTypeId = (int)NGOtype; NewNGO.NGOType = NGOTypeId; } } //NewNGO.StateId = reg.stateId;// string.IsNullOrEmpty(reg.stateId) ? -1: Convert.ToInt32(reg.stateId); //NewNGO.CityId = reg.cityId; //NewNGO.CountryId = reg.countryID; NewNGO.CityName = reg.cityName; NewNGO.StateName = reg.stateName; NewNGO.CountryName = reg.countryName; NewNGO.UserId = reg.UserId; Entity.tbl_UserNGOEndorsement.Add(NewNGO); Entity.SaveChanges(); return(true); } else { result.NGORegisterationNO = string.IsNullOrEmpty(reg.RegisterationNo) ? "" : reg.RegisterationNo; result.NGORegAt = string.IsNullOrEmpty(reg.Registeredat) ? "" : reg.Registeredat; if (reg.canEndorse) { if (!string.IsNullOrEmpty(reg.NGOSector)) { StoryCategory cate = (StoryCategory)Enum.Parse(typeof(StoryCategory), reg.NGOSector); int NGOSectorId = (int)cate; result.NGOSector = NGOSectorId; } if (!string.IsNullOrEmpty(reg.NGOType)) { NGOType NGOtype = (NGOType)Enum.Parse(typeof(NGOType), reg.NGOType); int NGOTypeId = (int)NGOtype; result.NGOType = NGOTypeId; } } else { result.NGOSector = 0; result.NGOType = 0; } result.CityName = reg.cityName; result.StateName = reg.stateName; result.CountryName = reg.countryName; result.UserId = reg.UserId; Entity.SaveChanges(); } return(true); } catch (Exception ex) { throw ex; } }