public static ResponseModels ForgotPassword(ForgotPasswordModels models) { ResponseModels result = new ResponseModels(); result.Response = MethodResponse.Success; DataSet ds = new DataSet(); SqlParameter[] pr = new SqlParameter[] { new SqlParameter("@Email", models.Email), new SqlParameter("@Password", models.Password), new SqlParameter("@Mode", "ForgotPassword") }; ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStr(), CommandType.StoredProcedure, "sp_Login", pr); if (ds != null && ds.Tables[0].Rows.Count > 0) { result.Email = ds.Tables[0].Rows[0]["Email"].ToString(); result.UserID = Convert.ToInt32(ds.Tables[0].Rows[0]["id"].ToString()); result.FirstName = ds.Tables[0].Rows[0]["StudentFirstName"].ToString(); result.LastName = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.ORG_ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ORGID"].ToString()); result.Response = MethodResponse.Success; } else { result.Response = MethodResponse.Invalid_Email_And_Password; } return(result); }
public ActionResult Create(SupplierViewModels model) { var data = new ResponseModels(); try { // TODO: Add insert logic here EasyBuyEntities db = new EasyBuyEntities(); var checkSupplier = db.Suppliers.Where(p => p.Name == model.Name).FirstOrDefault(); if (checkSupplier == null) { Models.Supplier supplier = new Models.Supplier { Name = model.Name, Phone = model.Phone, City = model.City, Area = model.Area, Address = model.Address }; db.Suppliers.Add(supplier); db.SaveChanges(); data.result = 1; } else { data.msg = "該廠商已存在,請重新建立。"; } } catch (Exception e) { data.msg = e.Message; } return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult Login(LoginModels models) { try { if (ModelState.IsValid) { ResponseModels result = clsLoginBL.Login(models); if (result.Response == MethodResponse.Success) { Session[SessionVariable.LoginUserDetails] = result; Session["FirstName"] = result.FirstName; Session[SessionVariable.UserID] = result.UserID; return(RedirectToAction("Index", "Test")); } else { ModelState.AddModelError("", "Invalid Email or Password."); } } } catch (Exception ex) { ViewBag.Error = ex.ToString(); } models.InstituteList = clsLoginBL.GetInstituteList(); return(View(models)); }
// // GET: /Live/ public ActionResult MySession(string id) { if (!string.IsNullOrEmpty(id)) { ResponseModels models = new ResponseModels(); models = (ResponseModels)Session[SessionVariable.LoginUserDetails]; DataSet ds = CommanFunction.GetDataSet("Select * from tbl_ScheduleClassMaster where ClassID=" + CommanFunction.UrlDecode(id)); if (ds != null && ds.Tables[0].Rows.Count > 0) { string s = "https://api.braincert.com/v2/getclasslaunch?apikey=008ue0CmckjvtN3czdIi&class_id=" + ds.Tables[0].Rows[0]["ClassID"].ToString() + "&userId=" + models.UserID.ToString() + "&userName="******"&isTeacher=0&lessonName=" + ds.Tables[0].Rows[0]["LessionName"].ToString() + "&courseName=" + ds.Tables[0].Rows[0]["LessionName"].ToString() + ""; s = "http://roken4life.com/online/Class.aspx?Method=GETLINK&class_id=" + ds.Tables[0].Rows[0]["ClassID"].ToString() + "&userId=" + models.UserID.ToString() + "&userName="******"&isTeacher=0&lessonName=" + ds.Tables[0].Rows[0]["LessionName"].ToString() + "&courseName=" + ds.Tables[0].Rows[0]["LessionName"].ToString() + ""; s = CommanFunction.GetResponse(s); ViewBag.Src = s; Response.Redirect(s); } return(View()); } else { ViewBag.ErrorText = "Somthing worng"; return(View()); } }
public void OneTimeSetup() { var data = new ResponseModels <Policy> { IsValid = true, Message = string.Empty, Models = new List <Policy> { new Policy { IdPolicy = "64cceef9-3a01-49ae-a23b-3761b604800b", AmountInsured = 1825.89M, Email = "*****@*****.**", InceptionDate = new DateTime(2016, 6, 1, 3, 33, 32), InstallmentPayment = true, IdClient = "e8fd159b-57c4-4d36-9bd7-a59ca13057bb" } } }; _policiesRepositoryMock = new Mock <IRepository <Policy> >(); _policiesRepositoryMock.Setup(m => m.GetData()).Returns(data); _policyService = new PolicyService(_policiesRepositoryMock.Object); }
public ResponseModels <MsGroup> Inquiry(GroupReqModel req) { var methodName = MethodBase.GetCurrentMethod().Name; try { _logger.LogInformation($"Start Function => {methodName}, Parameters => {JsonSerializer.ToJsonString(req)}"); var query = _context.MsGroup.Where(r => string.IsNullOrEmpty(req.Filter) || r.Name.Contains(req.Filter)); var datas = query.OrderByDescending(r => r.CreateDate).Skip((req.Page - 1) * req.RowsPerPage).Take(req.RowsPerPage).ToList(); var total = query.Count(); var result = new ResponseModels <MsGroup> { Success = true, Datas = datas, Total = total }; _logger.LogInformation($"Finish Function => {methodName}, Result => {JsonSerializer.ToJsonString(result)}"); return(result); } catch (Exception ex) { var messageError = $"Error Function => {methodName}"; _logger.LogError(ex, messageError); throw new ArgumentException(messageError, ex); } }
public async Task <Response> Update(User item) { if (item != null) { return(await _userDAL.Update(item)); } return(await ResponseModels.FailedResponseModel("Object cannot be null.")); }
public async Task <Response> Delete(int id) { if (NullPropertyVerifier.IsIdValid(id)) { return(await _userDAL.Delete(id)); } return(await ResponseModels.FailedResponseModel($"{id.toString()} is not a valid ID.")); }
public async Task <Response> Insert(User item) { NullPropertyVerifier.IsAnyPropertyNull(item); if (!NullPropertyVerifier.NullProperties.HasNullProperties()) { return(await _userDAL.Insert(item)); } else { return(await ResponseModels.FailedResponseModel(NullPropertyVerifier.NullProperties.NullPropertiesToSting())); } }
public async Task <Response> Insert(User item) { try { using var context = _db; await context.Users.AddAsync(item); await context.SaveChangesAsync(); return(await ResponseModels.SuccessResponseModel()); } catch (Exception e) { return(await ResponseModels.FailedResponseModel(e.ToString())); } }
public void OneTimeSetup() { var data = new ResponseModels <Client> { IsValid = true, Message = string.Empty, Models = new List <Client> { new Client { IdClient = "a0ece5db-cd14-4f21-812f-966633e7be86", Name = "Britney", Email = "*****@*****.**", Role = "admin" } } }; var policyLinked = new ResponseModel <PolicyDTO> { IsValid = true, Message = string.Empty, Model = new PolicyDTO { IdPolicy = "7b624ed3-00d5-4c1b-9ab8-c265067ef58b", AmountInsured = 399.89M, Email = "*****@*****.**", InceptionDate = new DateTime(2015, 7, 6, 6, 55, 49), InstallmentPayment = true, IdClient = "a0ece5db-cd14-4f21-812f-966633e7be86" }, }; _clientsRepositoryMock = new Mock <IRepository <Client> >(); _clientsRepositoryMock.Setup(m => m.GetData()).Returns(data); _policyServiceMock = new Mock <IPolicyService>(); _policyServiceMock.Setup(m => m.GetPolicyById(idPolicyLinked)).Returns(policyLinked); _policyServiceMock.Setup(m => m.GetPolicyById(idPolicyNotLinked)) .Returns(new ResponseModel <PolicyDTO> { IsValid = false, Message = string.Format(MessageValues.POLICY_NOT_FOUND, "id", idPolicyNotLinked) }); _clientService = new ClientService(_clientsRepositoryMock.Object, _policyServiceMock.Object); }
public ActionResult SessionList() { ScheduleClassModels model = new ScheduleClassModels(); if (Session[SessionVariable.LoginUserDetails] != null) { ResponseModels models = new ResponseModels(); models = (ResponseModels)Session[SessionVariable.LoginUserDetails]; model.ScheduleClassList = CommanFunction.MyScheduleClassList(models.UserID); } else { return(RedirectToAction("Login", "Home")); } return(View(model)); }
public ResponseModels <Policy> GetData() { var result = new ResponseModels <Policy>(); var policies = ResourcesHandler.Load <Policy>(AddressValues.POLICIES, TableNameValues.POLICIES); if (!policies.Any()) { result.NotValidResponse(MessageValues.POLICIES_REPOSITORY_EMPTY); return(result); } result.IsValid = true; result.Models = policies.Select(c => (Policy) new Policy().InjectFrom(c)); return(result); }
public ResponseModels <Client> GetData() { var result = new ResponseModels <Client>(); var clients = ResourcesHandler.Load <Client>(AddressValues.CLIENTS, TableNameValues.CLIENTS); if (!clients.Any()) { result.NotValidResponse(MessageValues.CLIENTS_REPOSITORY_EMPTY); return(result); } result.IsValid = true; result.Models = clients.Select(c => (Client) new Client().InjectFrom(c)); return(result); }
public ResponseModels <MsQuestion> Inquiry(MsQuestionReqModel req) { var result = new ResponseModels <MsQuestion>(); try { result = _msQuestionService.Inquiry(req); return(result); } catch { return(new ResponseModels <MsQuestion> { Message = result.Message, StatusCode = StatusCodes.Status500InternalServerError }); } }
public ActionResult MemberProfile() { ResponseModels _ResponseModel = new ResponseModels(); ProfileModels model = new ProfileModels(); if (Session[SessionVariable.LoginUserDetails] != null) { _ResponseModel = (ResponseModels)Session[SessionVariable.LoginUserDetails]; model.FirstName = _ResponseModel.FirstName; model.LastName = _ResponseModel.LastName; model.UserID = _ResponseModel.UserID; Session[SessionVariable.UserID] = _ResponseModel.UserID; return(View(model)); } else { return(RedirectToAction("Login")); } }
public ResponseModels <PolicyDTO> GetPoliciesLinkedByName(string name) { var result = new ResponseModels <PolicyDTO>(); if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(string.Empty, MessageValues.ARGUMENT_NULL); } var clientDTO = GetClientByName(name); if (!clientDTO.IsValid) { result.NotValidResponse(clientDTO.Message); return(result); } return(_policiesService.GetPoliciesLinkedByIdClient(clientDTO.Model.IdClient)); }
public async Task <Response> Delete(int id) { try { using var context = _db; context .Users .Remove(new User() { Id = id }); await context.SaveChangesAsync(); return(await ResponseModels.SuccessResponseModel()); } catch (Exception e) { return(await ResponseModels.FailedResponseModel(e.ToString())); } }
public static ResponseModels Login(LoginModels models) { ResponseModels result = new ResponseModels(); result.Response = MethodResponse.Success; DataSet ds = new DataSet(); SqlParameter[] pr = new SqlParameter[] { new SqlParameter("@Email", models.EmailID), new SqlParameter("@ORG_ID", models.ORG_ID), new SqlParameter("@Password", models.Password), new SqlParameter("@Mode", "StudentLogin") }; ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStr(), CommandType.StoredProcedure, "sp_Login", pr); if (ds != null && ds.Tables[0].Rows.Count > 0) { result.Email = ds.Tables[0].Rows[0]["Email"].ToString(); result.UserID = Convert.ToInt32(ds.Tables[0].Rows[0]["id"].ToString()); result.FirstName = ds.Tables[0].Rows[0]["Name"].ToString(); result.LastName = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.MobilePhone = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Address = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Twitter = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Facebook = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.LinkedIn = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Skyup = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Gender = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.InstituteName = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Twitter = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Twitter = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.Twitter = ds.Tables[0].Rows[0]["StudentLastName"].ToString(); result.ORG_ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ORG_ID"].ToString()); result.Response = MethodResponse.Success; } else { result.Response = MethodResponse.Invalid_Email_And_Password; } return(result); }
public ResponseModels <PolicyDTO> GetPoliciesLinkedByIdClient(string idClient) { var result = new ResponseModels <PolicyDTO>(); if (string.IsNullOrEmpty(idClient)) { throw new ArgumentNullException(string.Empty, MessageValues.ARGUMENT_NULL); } var policies = _policiesRepository.GetData(); var policiesLinked = policies.Models.Where(p => p.IdClient == idClient); if (!policiesLinked.Any()) { result.NotValidResponse(MessageValues.CLIENT_NOT_LINKED_POLICIES); return(result); } result.IsValid = true; result.Models = policiesLinked.Select(pl => (PolicyDTO) new PolicyDTO().InjectFrom(pl)); return(result); }