public DataTable ResetPassword(ForgotPassword data) { var res = ClsDatabase.ExecuteDatatableSP("SPUserChangePasswordFirst", ClsDatabase.GenParameters("@Mobile", data.Mobile, "@NewPassWord", data.NewPassword), 1); return(res); }
public IHttpActionResult SaveUserArea(Area data) { var result = new Response(); try { var userWithClaims = (ClaimsPrincipal)User; var userCo = Convert.ToInt64(userWithClaims.Claims.First(c => c.Type == "userId").Value); var res = ClsDatabase.ExecuteDatatableSP("SPUserSetVillageAndRegion", ClsDatabase.GenParameters("@UserCo", userCo, "@VillageCo", data.VillageId), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult LoadAudience(Info data) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPAudienceLoad", ClsDatabase.GenParameters("@AudienceCo", data.AudienceId), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult SavePackageCourse(Package data) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPPackageCourseSave", ClsDatabase.GenParameters("@PackageCo", data.PackageId, "@CourseCo", data.CourseId), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult SaveStep(CourseStep data) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPCourseStepSave", ClsDatabase.GenParameters("@CourseStepCo", data.CourseStepId, "@Deleted", data.Deleted, "@Title", data.Title, "@Keyword", data.Keyword, "@CourseCo", data.CourseId, "@Type", data.Type, "@IsFree", data.IsFree, "@Index ", 0, "@EndDateTime", data.EndDateTime, "@StartDateTime", data.StartDateTime, "@HasFile", data.HasFile, "@FileUrl", data.FileUrl), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult SavePackage(Package data) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPPackageSave", ClsDatabase.GenParameters("@PackageCo", data.PackageId, "@Deleted", data.Deleted, "@Title", data.Title, "@Description", data.Description, "@StartDateTime", data.StartDateTime, "@IsActive", data.IsActive, "@PublishDate", data.PublishDate, "@DiscountPercentage", data.DiscountPercentage, "@IsOffered", data.IsOffered, "@Index", data.Index, "@StageCo", data.StageId, "@Type", data.Type, "@System", data.System, "@AudienceCo", data.AudienceId), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult SaveCourse(Courses data) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPCourseSave", ClsDatabase.GenParameters("@CourseCo", data.CourseId, "@Deleted", data.Deleted, "@Title", data.Title, "@Description", data.Description, "@Keyword", data.Keyword, "@IsActive", data.IsActive, "@PublishDate", data.PublishDate, "@Type", data.Type, "@Price", data.Price, "@IsOffered", data.IsOffered, "@Index", data.Index, "@PriceRegion1", data.PriceRegion1, "@PriceRegion2", data.PriceRegion2, "@PriceRegion3", data.PriceRegion3, "@StartDateTime", data.StartDateTime, "@System", data.System, "@StepCount", data.StepCount, "@CourseStartDescription", data.CourseStartDescription, "@TeacherCo", data.TeacherId, "@StageCo", data.StageId), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult GetStream() { //get user Id var userWithClaims = (ClaimsPrincipal)User; var userCo = Convert.ToInt64(userWithClaims.Claims.First(c => c.Type == "userId").Value); var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPLiveStream", ClsDatabase.GenParameters("@UserCo", userCo), 1); if (result.Code == 200) { result.Message = "Success"; } result.Code = (int)ResponseType.Ok; result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult GetTestResult(string id) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPCHTGetTestResult", ClsDatabase.GenParameters("@SignalCo", id), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult TestAnswer(TestAnswerModel data) { //get user Id var userWithClaims = (ClaimsPrincipal)User; var userCo = Convert.ToInt64(userWithClaims.Claims.First(c => c.Type == "userId").Value); var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPCHTTestSaveResult", ClsDatabase.GenParameters("@SignalCo", data.TestId, "@UserCo", userCo, "@Res", data.Answer), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public IHttpActionResult SaveTest(TestModel data) { var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPCHTTestSave", ClsDatabase.GenParameters("@SignalCo", data.Id, "@CourseStepCo", data.CourseId, "@Question", data.Question, "@Answer1", data.Answer1, "@Answer2", data.Answer2, "@Answer3", data.Answer3, "@Answer4", data.Answer4, "@Answer5", data.Answer5), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var form = await context.Request.ReadFormAsync(); var res = ClsDatabase.ExecuteDatatableSP("SPUserLogin", ClsDatabase.GenParameters("@Mobile", context.UserName, "@PassWord", context.Password), 1); if (res.Rows[0]["message"].ToString() == "wrong") { var err = context.Error; context.SetError("invalid_grant", "Invalid username or password"); return; } if (res.Rows[0]["message"].ToString() == "Succeed") { var claims = new List <Claim>(); claims.Add(new Claim("userId", res.Rows[0]["UserCode"].ToString())); var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); string secret = ""; if (res.Rows[0]["UserRole"].ToString() == "5") { identity.AddClaim(new Claim(ClaimTypes.Role, "Member")); secret = "4842591949"; } else if (res.Rows[0]["UserRole"].ToString() == "3") { identity.AddClaim(new Claim(ClaimTypes.Role, "Admin")); secret = "8592737698"; } var props = new AuthenticationProperties(new Dictionary <string, string> { { "secret", secret } }); var ticket = new AuthenticationTicket(identity, props); context.Validated(ticket); } //if (context.UserName == "1") //{ // var claims = new List<Claim>(); // claims.Add(new Claim("userId", "1")); // var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); // identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); // identity.AddClaim(new Claim(ClaimTypes.Role, "Admin")); // context.Validated(identity); //} //else //{ // var claims = new List<Claim>(); // claims.Add(new Claim("userId", "2")); // var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); // identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); // identity.AddClaim(new Claim(ClaimTypes.Role, "Member")); // context.Validated(identity); //} }
public DataTable VerifyCode(Register data) { var res = ClsDatabase.ExecuteDatatableSP("SPUserVerifyCode", ClsDatabase.GenParameters("@Mobile", data.Mobile, "@VerifyCode", data.VerificationCode), 1); return(res); }
public DataTable ForgotPassword(Register data) { var res = ClsDatabase.ExecuteDatatableSP("SPUserForgetPassword", ClsDatabase.GenParameters("@Mobile", data.Mobile), 1); if (Convert.ToInt32(res.Rows[0][1]) == 0) { Sendsms(data.Mobile, "کد ورود : " + res.Rows[0][2] + Environment.NewLine + "تاملند مدرسه ای برای همه ", 1, "", ""); } return(res); }
public IHttpActionResult SaveInfo(Info data) { var result = new Response(); try { //string cardfilename = GetHashString(data.CardFileName); // string cfilename = cardfilename; if (!string.IsNullOrEmpty(data.CardImage)) { byte[] cardbytes = Convert.FromBase64String(data.CardImage); Image image; using (MemoryStream ms = new MemoryStream(cardbytes)) { image = Image.FromStream(ms); } var edbytess = Convert.FromBase64String(data.CardImage); using (var imageFile = new FileStream(HttpContext.Current.Server.MapPath("~/Files/card/" + data.CardFileName), FileMode.Create)) { imageFile.Write(cardbytes, 0, edbytess.Length); imageFile.Flush(); } } // string myfilename = GetHashString(data.EduFileName); // string filename = myfilename; if (!string.IsNullOrEmpty(data.EduImage)) { byte[] edubytes = Convert.FromBase64String(data.EduImage); Image image2; using (MemoryStream ms = new MemoryStream(edubytes)) { image2 = Image.FromStream(ms); } var edubytess = Convert.FromBase64String(data.EduImage); using (var imageFile = new FileStream(HttpContext.Current.Server.MapPath("~/Files/edu/" + data.EduFileName), FileMode.Create)) { imageFile.Write(edubytes, 0, edubytess.Length); imageFile.Flush(); } } var userWithClaims = (ClaimsPrincipal)User; var userCo = Convert.ToInt64(userWithClaims.Claims.First(c => c.Type == "userId").Value); // var userCo = 21262; var res = ClsDatabase.ExecuteDatatableSP("SPUserProfileChange", ClsDatabase.GenParameters("@UserCo", userCo, "@Email", data.Email, "@FullName", data.FullName, "@Gender", data.Gender, "@BD", data.BirthDate, "@AudienceCo", data.AudienceId, "IDCardPicAddress", data.CardFileName, "@CerificetePicAddress", data.EduFileName), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = ex; return(Ok(result)); } }