public IHttpActionResult ViewAchievement(JObject requestParams) { var data = string.Empty; int CompID; int AchievementID = 0; try { var identity = MyAuthorizationServerProvider.AuthenticateUser(); if (identity != null) { CompID = identity.CompId; if (!string.IsNullOrEmpty(requestParams["AchievementID"].ToString())) { AchievementID = (int)requestParams["AchievementID"]; } var ds = AchivementBL.GetAchievements(CompID, AchievementID); if (ds.Tables.Count > 0) { DataTable dt = ds.Tables["Data"]; data = Utility.ConvertDataSetToJSONString(dt); data = Utility.Successful(data); } else { data = ConstantMessages.WebServiceLog.GenericErrorMsg; data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } } else { data = Utility.AuthenticationError(); data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } } catch (Exception ex) { data = ex.Message; data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } return(new APIResult(Request, data)); }
public IHttpActionResult CreateAchievement(JObject requestParams) { var data = string.Empty; string AchievementTitle = string.Empty; string AchivementDescription = string.Empty; string LongDescription = string.Empty; int CompID; string CreatedBy = string.Empty; try { var identity = MyAuthorizationServerProvider.AuthenticateUser(); if (identity != null) { if (!string.IsNullOrEmpty(requestParams["AchievementTitle"].ToString()) && !string.IsNullOrEmpty(requestParams["AchivementDescription"].ToString()) && !string.IsNullOrEmpty(requestParams["LongDescription"].ToString())) { CompID = identity.CompId; CreatedBy = identity.UserID; if (!string.IsNullOrEmpty(requestParams["AchievementTitle"].ToString())) { AchievementTitle = requestParams["AchievementTitle"].ToString(); } else { AchievementTitle = string.Empty; } if (!string.IsNullOrEmpty(requestParams["AchivementDescription"].ToString())) { AchivementDescription = requestParams["AchivementDescription"].ToString(); } else { AchivementDescription = string.Empty; } if (!string.IsNullOrEmpty(requestParams["LongDescription"].ToString())) { LongDescription = requestParams["LongDescription"].ToString(); } else { LongDescription = string.Empty; } var ds = AchivementBL.CreateAchievement(CompID, 0, AchievementTitle, AchivementDescription, LongDescription, CreatedBy); if (ds.Tables.Count > 0) { DataTable dt = ds.Tables["Data"]; if (dt.Rows[0]["ReturnCode"].ToString() == "1") { data = Utility.ConvertDataSetToJSONString(dt); data = Utility.Successful(data); } else { data = ConstantMessages.WebServiceLog.GenericErrorMsg; data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } } else { data = ConstantMessages.WebServiceLog.GenericErrorMsg; data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } } else { data = ConstantMessages.WebServiceLog.InValidValues; data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } } else { data = Utility.AuthenticationError(); data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } } catch (Exception ex) { data = ex.Message; data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data); } return(new APIResult(Request, data)); }