partial void BeforeTransform(Bespoke.PosEntt.SalesOrders.Domain.SalesOrder item, Bespoke.PosEntt.Adapters.SnbWebApi.PostSalesOrdersRequest destination) { var context = new SphDataContext(); if (m_products.Count == 0) { var query = context.CreateQueryable <Bespoke.PosEntt.Products.Domain.Product>() .Where(p => p.Id != "0"); var productRepos = ObjectBuilder.GetObject <IRepository <Bespoke.PosEntt.Products.Domain.Product> >(); var lo = productRepos.LoadAsync(query, 1, 200, false).Result; m_products.AddRange(lo.ItemCollection); } if (m_surcharges.Count == 0) { var surchargeQuery = context.CreateQueryable <Bespoke.PosEntt.SurchargeAddOns.Domain.SurchargeAddOn>() .Where(p => p.Id != "0"); var surchargeRepos = ObjectBuilder.GetObject <IRepository <Bespoke.PosEntt.SurchargeAddOns.Domain.SurchargeAddOn> >(); var scLo = surchargeRepos.LoadAsync(surchargeQuery, 1, 200, false).Result; m_surcharges.AddRange(scLo.ItemCollection); } if (m_categories.Count == 0) { var categoryQuery = context.CreateQueryable <Bespoke.PosEntt.ItemCategories.Domain.ItemCategory>() .Where(p => p.Id != "0"); var categoryRepos = ObjectBuilder.GetObject <IRepository <Bespoke.PosEntt.ItemCategories.Domain.ItemCategory> >(); var categoriesLo = categoryRepos.LoadAsync(categoryQuery, 1, 200, false).Result; m_categories.AddRange(categoriesLo.ItemCollection); } }
public async Task <ActionResult> TimeOut(string id) { var context = new SphDataContext(); var user = await context.LoadOneAsync <Pengguna>(x => x.MyKad == User.Identity.Name); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); var name = user == null ? "" : user.Nama; var setting = (await context.LoadOneAsync <PercubaanSesi>(x => x.MyKad == User.Identity.Name && x.SesiUjianId == id)) ?? new PercubaanSesi { No = Guid.NewGuid().ToString(), MyKad = User.Identity.Name, SesiUjianId = id, Bilangan = 0, NamaUjian = sesi.NamaUjian, Program = sesi.NamaProgram, NamaPengguna = name, Tarikh = DateTime.Now, Id = Guid.NewGuid().ToString() }; setting.Bilangan += 1; using (var session = context.OpenSession()) { session.Attach(setting); await session.SubmitChanges(); } return(Json(setting)); }
public async Task <ActionResult> ResetPassword(string id) { var context = new SphDataContext(); var setting = await context.LoadOneAsync <Setting>(x => x.Id == id); var model = new ResetPaswordModel { IsValid = true, Id = id }; if (null == setting) { model.IsValid = false; model.Mesage = "The link is invalid"; return(View(model)); } model.Email = setting.UserName; if ((DateTime.Now - setting.CreatedDate).TotalMinutes > 10) { model.IsValid = false; model.Mesage = "The link has expired"; return(View(model)); } var user = Membership.FindUsersByEmail(setting.UserName); if (user.Count == 0) { model.IsValid = false; model.Mesage = "Cannot find any user with email " + model.Email; } model.Email = setting.UserName; return(View(model)); }
public async Task <ActionResult> UpdateUser(UserProfile profile) { var context = new SphDataContext(); var userprofile = await context.LoadOneAsync <UserProfile>(p => p.UserName == User.Identity.Name) ?? new UserProfile(); userprofile.UserName = User.Identity.Name; userprofile.Email = profile.Email; userprofile.Telephone = profile.Telephone; userprofile.FullName = profile.FullName; userprofile.StartModule = profile.StartModule; userprofile.Language = profile.Language; if (userprofile.IsNewItem) { userprofile.Id = userprofile.UserName.ToIdFormat(); } using (var session = context.OpenSession()) { session.Attach(userprofile); await session.SubmitChanges(); } this.Response.ContentType = "application/json; charset=utf-8"; return(Content(JsonConvert.SerializeObject(userprofile))); }
private async Task <IpTraitViewModel> GetIpTraitViewModelAsync(string id) { var context = new SphDataContext(); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); var user = await context.LoadOneAsync <Pengguna>(x => x.MyKad == sesi.MyKad); var ujian = await context.LoadOneAsync <Ujian>(x => x.Id == sesi.NamaUjian); var permohonan = await context.LoadOneAsync <Permohonan>(x => x.PermohonanNo == sesi.NamaProgram); if (null == sesi || null == user) { return(null); } var vm = new IpTraitViewModel(sesi, user) { Permohonan = permohonan, Ujian = ujian }; vm.Recommendation = await context.LoadOneAsync <IpRecommendation>(x => x.Skor == vm.Result); if (null == vm.Recommendation) { throw new InvalidOperationException("Cannot find IpRecommendation for " + vm.Result); } return(vm); }
public async Task <ActionResult> PrintIndikatorIso(string id) { var context = new SphDataContext(); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); var user = await context.LoadOneAsync <Pengguna>(x => x.MyKad == sesi.MyKad); var ujianTask = context.LoadOneAsync <Ujian>(x => x.Id == sesi.NamaUjian); var permohonanTask = context.LoadOneAsync <Permohonan>(x => x.PermohonanNo == sesi.NamaProgram); var recommendationTask = context.LoadAsync(context.CreateQueryable <IsoRecommendation>()); var soalanTask = context.LoadAsync(context.CreateQueryable <Soalan>().Where(x => x.NamaUjian == "Inventori Stres Organisasi (ISO)"), 1, 120, true); await Task.WhenAll(ujianTask, permohonanTask, recommendationTask, soalanTask); var rlo = await recommendationTask; var soalanLo = await soalanTask; if (null == sesi) { return(HttpNotFound("Cannot find SesiUjian " + id)); } if (null == user) { return(HttpNotFound("Cannot find user with MyKad " + sesi.MyKad)); } var vm = new IsoTraitViewModel(sesi, user, rlo.ItemCollection, soalanLo.ItemCollection) { Permohonan = await permohonanTask, Ujian = await ujianTask, Pengguna = user }; return(View("Indikator-Iso", vm)); }
public async Task <ActionResult> PrintPpkpKhusus(string id) { var context = new SphDataContext(); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); var user = await context.LoadOneAsync <Pengguna>(x => x.MyKad == sesi.MyKad); var ujianTask = context.LoadOneAsync <Ujian>(x => x.Id == sesi.NamaUjian); var permohonanTask = context.LoadOneAsync <Permohonan>(x => x.PermohonanNo == sesi.NamaProgram); var recommendationTask = context.LoadAsync(context.CreateQueryable <PpkpRecommendation>()); var skorTask = context.LoadAsync(context.CreateQueryable <SkorPpkp>(), 1, 150, true); await Task.WhenAll(ujianTask, permohonanTask, recommendationTask, skorTask); var rlo = await recommendationTask; var skorLo = await skorTask; if (null == sesi) { return(HttpNotFound("Cannot find SesiUjian " + id)); } if (null == user) { return(HttpNotFound("Cannot find user with MyKad " + sesi.MyKad)); } var vm = new PpkpTraitViewModel(sesi, rlo.ItemCollection.ToArray(), skorLo.ItemCollection.ToArray()) { Permohonan = await permohonanTask, Ujian = await ujianTask, Pengguna = user }; return(View("ppkp.khusus", vm)); }
public async Task <IHttpActionResult> AddContactToGroup(string id, string group) { var repos = ObjectBuilder.GetObject <IRepository <AddressBook> >(); var context = new SphDataContext(); var contact = await repos.LoadOneAsync(id); if (null == contact) { return(NotFound($"Contact with Id {id} is not found")); } if (contact.Groups.Contains(group)) { return(Ok(new { message = $"{contact.CompanyName} is already in {group}" })); } contact.Groups.Add(group); using (var session = context.OpenSession()) { session.Attach(contact); await session.SubmitChanges("AddGroup", new Dictionary <string, object> { { "username", User.Identity.Name } }); } // wait until the worker process it await Task.Delay(1000); return(Ok(new { message = $"{contact.CompanyName} has been added to {group}" })); }
private async Task CreateElasticsearchTemplateAsync() { string uri = $"_template/{ConfigurationManager.ElasticSearchIndex}_rts"; var getResponse = await m_client.GetAsync(uri); if (getResponse.StatusCode != HttpStatusCode.NotFound) { return; } var context = new SphDataContext(); var entityDefinitions = context.LoadFromSources <EntityDefinition>(); var mappings = from ed in entityDefinitions where !ExcludeTypes.Contains(ed.Name) let map = ed.GetElasticsearchMapping().Trim() let trim = map.Trim() select trim.Substring(1, trim.Length - 2).Trim(); var template = $@" {{ ""template"": ""{ConfigurationManager.ElasticSearchIndex}_rts_*"", ""aliases"": {{ ""{ConfigurationManager.ElasticSearchIndex}_rts"": {{}} }}, ""mappings"": {{ {mappings.ToString(",\r\n")} }} }}"; var response = await m_client.PutAsync(uri, new StringContent(template)); response.EnsureSuccessStatusCode(); }
public async Task RunAsync(Pickup pickup) { //pickup_event_new var pickupToEnttAcceptanceMap = new Integrations.Transforms.RtsPickupToEnttPlatformAcceptance(); var acceptanceList = new List <EnttAcceptance>(); var parentRow = await pickupToEnttAcceptanceMap.TransformAsync(pickup); parentRow.IsParent = true; acceptanceList.Add(parentRow); if (null != pickup.BabyConsignment) { var consignmentBabies = pickup.BabyConsignment.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] babiesWeight = { }; if (!string.IsNullOrEmpty(pickup.BabyWeigth)) { babiesWeight = pickup.BabyWeigth.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } var babiesHeight = pickup.BabyHeigth.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var babiesWidth = pickup.BabyWidth.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var babiesLength = pickup.BabyLength.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var index = 0; foreach (var babyConsignmentNo in consignmentBabies) { var consignmentChildRow = parentRow.Clone(); consignmentChildRow.Id = Guid.NewGuid().ToString(); consignmentChildRow.Parent = parentRow.ConsignmentNo; consignmentChildRow.IsParent = false; consignmentChildRow.ConsignmentNo = babyConsignmentNo; if (babiesWeight.Length == consignmentBabies.Length) { consignmentChildRow.Weight = GetDoubleValue(babiesWeight[index]); } else { consignmentChildRow.Weight = 0; } consignmentChildRow.Height = GetDoubleValue(babiesHeight[index]); consignmentChildRow.Length = GetDoubleValue(babiesLength[index]); consignmentChildRow.Width = GetDoubleValue(babiesWidth[index]); acceptanceList.Add(consignmentChildRow); index++; } } // foreach (var item in acceptanceList) { var context = new SphDataContext(); using (var session = context.OpenSession()) { session.Attach(item); await session.SubmitChanges(); } } }
private async Task <UserProfile> GetDesignation() { var username = User.Identity.Name; var directory = new SphDataContext(); var userProfile = await directory.LoadOneAsync <UserProfile>(p => p.UserName == username) ?? new UserProfile(); return(userProfile); }
public async Task <ActionResult> PrintTraitForHlp(string id) { var context = new SphDataContext(); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); var user = await context.LoadOneAsync <Pengguna>(x => x.MyKad == sesi.MyKad); var ujianTask = context.LoadOneAsync <Bespoke.epsikologi_ujian.Domain.Ujian>(x => x.Id == sesi.NamaUjian); var permohonanTask = context.LoadOneAsync <Bespoke.epsikologi_permohonan.Domain.Permohonan>( x => x.PermohonanNo == sesi.NamaProgram); await Task.WhenAll(ujianTask, permohonanTask); var query = context.CreateQueryable <SkorHlp>(); var lo = await context.LoadAsync(query, size : 1000); var scoreTables = lo.ItemCollection; var rq = context.CreateQueryable <HlpRecomendation>(); var rlo = await context.LoadAsync(rq, size : 200); var recommendations = rlo.ItemCollection; if (null == sesi) { return(HttpNotFound("Cannot find SesiUjian " + id)); } if (null == user) { return(HttpNotFound("Cannot find user with MyKad " + sesi.MyKad)); } var vm = new HlpTraitViewModel(sesi, user, scoreTables.ToArray(), recommendations.ToArray()) { Permohonan = await permohonanTask, Ujian = await ujianTask }; var viewName = "Trait-Hlp-" + user.Jantina; // const string STYLE = "border:3px solid red"; // return Pdf(viewName, vm, "~/Views/PrintReport/_MasterPage.NoHeader.cshtml", // x => x // .Replace($"id=\"KB{vm.KB.Point}\"", $"id=\"KB{vm.KB.Point}\" style=\"{STYLE}\"") // .Replace($"id=\"FR{vm.FR.Percentile}\"", $"id=\"FR{vm.FR.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"KT{vm.KT.Percentile}\"", $"id=\"KT{vm.KT.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"KC{vm.KC.Percentile}\"", $"id=\"KC{vm.KC.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"LP{vm.LP.Percentile}\"", $"id=\"LP{vm.LP.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"SM{vm.SM.Percentile}\"", $"id=\"SM{vm.SM.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"AS{vm.AS.Percentile}\"", $"id=\"AS{vm.AS.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"AF{vm.AF.Percentile}\"", $"id=\"AF{vm.AF.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"TL{vm.TL.Percentile}\"", $"id=\"TL{vm.TL.Percentile}\" style=\"{STYLE}\"") // .Replace($"id=\"DT{vm.DT.Percentile}\"", $"id=\"DT{vm.DT.Percentile}\" style=\"{STYLE}\""), true); return(View(viewName, vm)); }
public async Task <ActionResult> CountForRespondenDariJabatan() { var context = new SphDataContext(); var penyelaras = await context.LoadOneAsync <Pengguna>(x => x.MyKad == User.Identity.Name); var count = await context.GetCountAsync <Pengguna>(x => x.NamaJabatan == penyelaras.NamaJabatan); return(Json(new { hits = new { total = count } }, JsonRequestBehavior.AllowGet)); }
private static async Task SaveConsigmentRequest(ConsigmentRequest item) { var context = new SphDataContext(); using (var session = context.OpenSession()) { session.Attach(item); await session.SubmitChanges("Default"); } }
private static async Task SaveEstRegistration(EstRegistration EstRegistration) { var context = new SphDataContext(); using (var session = context.OpenSession()) { session.Attach(EstRegistration); await session.SubmitChanges("Default"); } }
private static async Task SaveSetting(Setting setting, string operation) { var context = new SphDataContext(); using (var session = context.OpenSession()) { session.Attach(setting); await session.SubmitChanges(operation); } }
public async Task <ActionResult> PsRequestPrepaid(string id) { var context = new SphDataContext(); LoadData <Wallet> lo = await GetWallet(id); if (null == lo.Source) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(new { success = false, status = "ERROR", message = $"Cannot find WalletCode with Id: {id}." }, JsonRequestBehavior.AllowGet)); } var generalLedger = new GeneralLedger(); generalLedger.Id = Guid.NewGuid().ToString(); var wallet = lo.Source; decimal noGstPrice = 0; decimal gstPrice = 0; decimal totalPrice = 0; noGstPrice = Convert.ToDecimal(wallet.TotalValue); gstPrice = noGstPrice * Convert.ToDecimal(0.06); totalPrice = noGstPrice + gstPrice; // required by payment gateway var model = new PaymentSwitchRequestModel(); model.TransactionId = GenerateCustomRefNo(generalLedger); model.TransactionAmount = noGstPrice; model.TransactionGST = gstPrice; model.PurchaseDate = DateTime.Now; model.Description = $"{m_applicationName} purchase topup by {User.Identity.Name} for RM{totalPrice} with Id: ({wallet.WalletCode})"; model.CallbackUrl = $"{m_baseUrl}/ost-payment/ps-response-prepaid"; //insert empty transaction into GL with reference no and type generalLedger.ReferenceNo = model.TransactionId; generalLedger.Type = "Prepaid"; using (var session = context.OpenSession()) { session.Attach(generalLedger); await session.SubmitChanges("Default"); } var rijndaelKey = new RijndaelEnhanced(m_paymentGatewayEncryptionKey); var dataToEncrypt = string.Format("{0}|{1}|{2}|{3}|{4}", model.TransactionId, model.TransactionAmount, model.TransactionGST, model.PurchaseDate.ToString("MM/dd/yyyy hh:mm:ss"), model.Description); if (!string.IsNullOrEmpty(model.CallbackUrl)) { dataToEncrypt += "|" + model.CallbackUrl; } var encryptedData = rijndaelKey.Encrypt(dataToEncrypt); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(new { success = true, status = "OK", id = m_paymentGatewayApplicationId, data = encryptedData, url = $"{m_paymentGatewayBaseUrl}/pay" }, JsonRequestBehavior.AllowGet)); }
private static async Task <OstRegisterStatusModel> CreateAccount(OstRegisterModel model) { var result = new OstRegisterStatusModel { Success = true, Status = "OK" }; Profile profile = new Profile(); profile.UserName = model.UserName; profile.FullName = model.FullName; profile.Email = model.Email; profile.Password = model.Password; var context = new SphDataContext(); var designation = await context.LoadOneAsync <Designation>(d => d.Name == model.Designation); if (null == designation) { result.Success = false; result.Status = $"Cannot find designation {model.Designation}"; return(result); } profile.Designation = model.Designation; profile.Roles = designation.RoleCollection.ToArray(); var em = Membership.GetUser(profile.UserName); if (null != em) { result.Success = false; result.Status = $"User {profile.UserName} already exist."; return(result); } try { Membership.CreateUser(profile.UserName, profile.Password, profile.Email); } catch (MembershipCreateUserException ex) { ObjectBuilder.GetObject <ILogger>().Log(new LogEntry(ex)); result.Success = false; result.Status = ex.Message; return(result); } Roles.AddUserToRoles(profile.UserName, profile.Roles); await CreateProfile(profile, designation); return(result); }
private static async Task <bool> AddUserAsync(Profile profile) { var context = new SphDataContext(); var userName = profile.UserName; if (string.IsNullOrWhiteSpace(profile.Designation)) { throw new ArgumentNullException("Designation for " + userName + " cannot be set to null or empty"); } var designation = await context.LoadOneAsync <Designation>(d => d.Name == profile.Designation); if (null == designation) { throw new InvalidOperationException("Cannot find designation " + profile.Designation); } var roles = designation.RoleCollection.ToArray(); var em = Membership.GetUser(userName); if (null != em) { profile.Roles = roles; em.Email = profile.Email; var originalRoles = Roles.GetRolesForUser(userName); if (originalRoles.Length > 0) { Roles.RemoveUserFromRoles(userName, originalRoles); } Roles.AddUserToRoles(userName, profile.Roles); Membership.UpdateUser(em); await CreateProfile(profile, designation); return(true); } try { Membership.CreateUser(userName, profile.Password, profile.Email); } catch (MembershipCreateUserException ex) { ObjectBuilder.GetObject <ILogger>().Log(new LogEntry(new Exception($"Fail to create User for device '{userName}', email :'{profile.Email}' and password : '******'", ex))); return(false); } Roles.AddUserToRoles(userName, roles); profile.Roles = roles; await CreateProfile(profile, designation); return(true); }
public async Task <ActionResult> Login(JpaLoginModel model, string returnUrl) { var logger = ObjectBuilder.GetObject <ILogger>(); if (ModelState.IsValid) { var directory = ObjectBuilder.GetObject <IDirectoryService>(); if (await directory.AuthenticateAsync(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); var context = new SphDataContext(); var profile = await context.LoadOneAsync <UserProfile>(u => u.UserName == model.UserName); await logger.LogAsync(new LogEntry { Log = EventLog.Security }); if (null != profile) { if (!profile.HasChangedDefaultPassword) { return(RedirectToAction("ChangePassword")); } if (returnUrl == "/" || returnUrl.Equals("/epsikologi", StringComparison.InvariantCultureIgnoreCase) || returnUrl.Equals("/epsikologi#", StringComparison.InvariantCultureIgnoreCase) || returnUrl.Equals("/epsikologi/", StringComparison.InvariantCultureIgnoreCase) || returnUrl.Equals("/epsikologi/#", StringComparison.InvariantCultureIgnoreCase) || string.IsNullOrWhiteSpace(returnUrl)) { return(Redirect("/epsikologi#" + profile.StartModule)); } } if (!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } return(Redirect("epsikologi#")); } var user = await directory.GetUserAsync(model.UserName); await logger.LogAsync(new LogEntry { Log = EventLog.Security, Message = "Login Failed" }); if (null != user && user.IsLockedOut) { ModelState.AddModelError("", "Your acount has beeen locked, Please contact your administrator."); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(View(model)); }
public async Task <ActionResult> PrintSesiUjianIndikator(string id) { var context = new SphDataContext(); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); if (null == sesi) { return(HttpNotFound("Cannot find SesiUjian " + id)); } return(View("Indikator-" + sesi.NamaUjian, sesi)); }
public async Task <ActionResult> ChangePassword(ChangePaswordModel model) { var userName = User.Identity.Name; if (!Membership.ValidateUser(userName, model.OldPassword)) { return(Json(new { success = false, status = "PASSWORD_INCORRECT", message = "Your old password is incorrect", user = userName })); } if (model.Password != model.ConfirmPassword) { return(Json(new { success = false, status = "PASSWORD_DOESNOT_MATCH", message = "Your password is not the same" })); } var user = Membership.GetUser(userName); if (null == user) { throw new Exception("Cannot find user"); } try { var valid = user.ChangePassword(model.OldPassword, model.Password); if (!valid) { return(Json(new { success = false, status = "ERROR_CHANGING_PASSWORD", message = "There's an error changing your password" })); } } catch (Exception ex) { return(Json(new { success = false, status = "EXCEPTION_CHANGING_PASSWORD", message = ex.Message })); } var context = new SphDataContext(); var profile = await context.LoadOneAsync <UserProfile>(u => u.UserName == User.Identity.Name); profile.HasChangedDefaultPassword = true; using (var session = context.OpenSession()) { session.Attach(profile); await session.SubmitChanges("Change password"); } if (Request.ContentType.Contains("application/json")) { this.Response.ContentType = "application/json; charset=utf-8"; return(Content(JsonConvert.SerializeObject(new { success = true, status = "OK" }))); } return(Redirect("/")); }
public async Task <ActionResult> Html(string id) { var context = new SphDataContext(); var form = await context.LoadOneAsync <EntityForm>(f => f.Route == id); var ed = await context.LoadOneAsync <EntityDefinition>(f => f.Id == form.EntityDefinitionId); var layout = string.IsNullOrWhiteSpace(form.Layout) ? "Html2ColsWithAuditTrail" : form.Layout; var vm = new FormRendererViewModel(ed, form); return(View(layout, vm)); }
//exec:6527072e-1302-4de8-cdbe-52968cfea0a4 public async Task <ActivityExecutionResult> CreateProfileAndMembershipAsync() { var result = new ActivityExecutionResult { Status = ActivityExecutionStatus.Success }; var item = this; var context = new SphDataContext(); var designation = await context.LoadOneAsync <Designation>(d => d.Name == "Responden"); var roles = designation.RoleCollection.ToArray(); var profile = new UserProfile { Id = this.Pengguna.Id, UserName = this.Pengguna.MyKad, Email = this.Pengguna.Emel, FullName = this.Pengguna.Nama, Designation = "Responden", HasChangedDefaultPassword = false, RoleTypes = string.Join(",", roles), StartModule = "responden-home", Language = "en-US" }; Console.WriteLine("done mapping user profile"); var exist = System.Web.Security.Membership.GetUser(profile.UserName); var existUserByEmail = System.Web.Security.Membership.GetUserNameByEmail(profile.Email); if ((null == exist) || (null == existUserByEmail)) { this.Password = System.Web.Security.Membership.GeneratePassword(6, 0); System.Web.Security.Membership.CreateUser(profile.UserName, this.Password, profile.Email); System.Web.Security.Roles.AddUserToRoles(profile.UserName, roles); Console.WriteLine("insert into user profile"); using (var session = context.OpenSession()) { session.Attach(profile); await session.SubmitChanges(); } //IsCreated = true; } result.NextActivities = new[] { "41cddfd4-0781-44b1-db25-cbef78c61352" }; return(result); }
private async Task DeleteEstRegistration(string id) { var context = new SphDataContext(); EstRegistration item = await GetEstRegistrationAsync(id); Console.WriteLine($"Preparing to delete EstRegistration with Id: {item.Id}"); Console.WriteLine($"==============================================="); using (var session = context.OpenSession()) { session.Delete(item); await session.SubmitChanges("Default"); } }
public async Task <ActionResult> IndikatorUkbp(string id) { var context = new SphDataContext(); var sesi = await context.LoadOneAsync <SesiUjian>(x => x.Id == id); var user = await context.LoadOneAsync <Pengguna>(x => x.MyKad == sesi.MyKad); var ujianTask = context.LoadOneAsync <Ujian>(x => x.Id == sesi.NamaUjian); var permohonanTask = context.LoadOneAsync <Permohonan>(x => x.PermohonanNo == sesi.NamaProgram); var querySkorUkbp = context.CreateQueryable <SkorUkbp>().Where(x => x.Jantina == user.Jantina || x.Jantina == "NA"); var scoreTask = context.LoadAsync(querySkorUkbp, 1, 200); var recommendationTask = context.LoadAsync(context.CreateQueryable <UkbpRecommendation>(), 1, 200); await Task.WhenAll(ujianTask, permohonanTask, scoreTask, recommendationTask); var scores = await scoreTask; var recommendations = await recommendationTask; if (null == sesi) { return(HttpNotFound("Cannot find SesiUjian " + id)); } if (null == user) { return(HttpNotFound("Cannot find user with MyKad " + sesi.MyKad)); } SesiUjian sesiA, sesiB; if (sesi.NamaUjian == "UKBP-A") { sesiA = sesi; sesiB = await context.LoadOneAsync <SesiUjian>(x => x.NamaUjian == "UKBP-B" && x.NamaProgram == sesi.NamaProgram && x.MyKad == sesi.MyKad); } else { sesiB = sesi; sesiA = await context.LoadOneAsync <SesiUjian>(x => x.NamaUjian == "UKBP-A" && x.NamaProgram == sesi.NamaProgram && x.MyKad == sesi.MyKad); } var vm = new UkbpTraitViewModel(sesiA, sesiB, scores.ItemCollection.ToArray(), recommendations.ItemCollection.ToArray()) { Permohonan = await permohonanTask, Ujian = await ujianTask, Pengguna = user }; return(View("Indikator-UKBP", vm)); }
private static async Task SetVerifyEmailFlag(string username) { var context = new SphDataContext(); var userProfile = await context.LoadOneAsync <UserProfile>(p => p.UserName == username); if (!userProfile.HasChangedDefaultPassword) { userProfile.HasChangedDefaultPassword = true; using (var session = context.OpenSession()) { session.Attach(userProfile); await session.SubmitChanges(); } } }
public async Task RunAsync(MailItem item) { var ipsExportMap = new Integrations.Transforms.IpsExportToEnttAcceptance(); var acceptance = await ipsExportMap.TransformAsync(item); var tn030 = item.FromIPS.IPSEvent.Single(m => m.TNCd == "TN030"); acceptance.DateTime = tn030.Date.Value; var context = new SphDataContext(); using (var session = context.OpenSession()) { session.Attach(acceptance); await session.SubmitChanges(); } }
private static async Task <UserProfile> CreateProfile(Profile profile, Designation designation) { if (null == profile) { throw new ArgumentNullException(nameof(profile)); } if (null == designation) { throw new ArgumentNullException(nameof(designation)); } if (string.IsNullOrWhiteSpace(designation.Name)) { throw new ArgumentNullException(nameof(designation), "Designation Name cannot be null, empty or whitespace"); } if (string.IsNullOrWhiteSpace(profile.UserName)) { throw new ArgumentNullException(nameof(profile), "Profile UserName cannot be null, empty or whitespace"); } var context = new SphDataContext(); var usp = await context.LoadOneAsync <UserProfile>(p => p.UserName == profile.UserName) ?? new UserProfile(); usp.UserName = profile.UserName; usp.FullName = profile.FullName; usp.Designation = profile.Designation; usp.Department = profile.Department; usp.Mobile = profile.Mobile; usp.Telephone = profile.Telephone; usp.Email = profile.Email; usp.RoleTypes = string.Join(",", profile.Roles); usp.StartModule = designation.StartModule; if (usp.IsNewItem) { usp.Id = profile.UserName.ToIdFormat(); } using (var session = context.OpenSession()) { session.Attach(usp); await session.SubmitChanges(); } return(usp); }
public async Task <ActionResult> VerifyEmail(string id) { ViewBag.success = true; ViewBag.status = "OK"; var context = new SphDataContext(); var setting = await context.LoadOneAsync <Setting>(x => x.Id == id); if (null == setting) { ViewBag.success = false; ViewBag.status = "The link is invalid."; return(View()); } if ((DateTime.Now - setting.CreatedDate).TotalHours > 3) { ViewBag.success = false; ViewBag.status = "The link has expired."; return(View()); } if (!setting.Key.Equals("VerifyEmail")) { ViewBag.success = false; ViewBag.status = "The link is not associated with verify email."; return(View()); } var username = Membership.GetUserNameByEmail(setting.UserName); if (null == username) { ViewBag.success = false; ViewBag.status = $"Cannot find any user with email {setting.UserName}."; return(View()); } // email address verification complete await SetVerifyEmailFlag(username); return(RedirectToAction("success", "ost-account", new { success = true, status = "OK", operation = "verify-email" })); }