コード例 #1
0
ファイル: UserHelper.cs プロジェクト: jochemstoel/EPONS
        public static List <Data.Models.Permission> GetActivePermissions(Data.Models.Account account)
        {
            Guid?selectedClientId = SelectedClientId;

            if (!selectedClientId.HasValue)
            {
                if (account.AccountType.Equals("SuperAdmin"))
                {
                    List <Data.Models.Permission> list = new List <Data.Models.Permission>();
                    list.Add(new Data.Models.Permission()
                    {
                        PermissionDescription = "Case Manager"
                    });

                    return(list);
                }

                return(new List <Data.Models.Permission>());
            }

            var tempList = account.Permissions.Where(p => p.GetClientId() == selectedClientId).ToList();

            if (account.AccountType.Equals("SuperAdmin") && tempList.Count(x => x.PermissionDescription.Equals("Case Manager")) == 0)
            {
                tempList.Add(new Data.Models.Permission()
                {
                    PermissionDescription = "Case Manager"
                });
            }

            return(tempList);
        }
コード例 #2
0
 public ServiceResponse <Data.Models.Account> CreateAccount(Data.Models.Account account)
 {
     try
     {
         _db.Accounts.Add(account);
         _db.SaveChanges();
         return(new ServiceResponse <Data.Models.Account>
         {
             IsSuccess = true,
             Message = "New account added",
             Time = DateTime.UtcNow,
             Data = account
         });
     }
     catch (Exception e)
     {
         return(new ServiceResponse <Data.Models.Account>
         {
             IsSuccess = false,
             Message = e.StackTrace,
             Time = DateTime.UtcNow,
             Data = account
         });
     }
 }
コード例 #3
0
        public RefreshLearnerDataSteps(TestContext testContext)
        {
            _testContext    = testContext;
            _fixture        = new Fixture();
            _startDate      = DateTime.Parse("2020-08-10");
            _submissionDate = DateTime.Parse("2020-11-09T16:53:17.293+00:00");
            _accountModel   = _fixture.Create <Data.Models.Account>();

            _apprenticeshipIncentive = _fixture.Build <ApprenticeshipIncentive>()
                                       .With(p => p.DateOfBirth, _startDate.AddYears(-26))
                                       .With(p => p.UKPRN, 10036143)
                                       .With(p => p.ULN, 9900084607)
                                       .With(p => p.ApprenticeshipId, 511526)
                                       .With(p => p.AccountId, _accountModel.Id)
                                       .With(p => p.AccountLegalEntityId, _accountModel.AccountLegalEntityId)
                                       .With(p => p.StartDate, _startDate)
                                       .Without(p => p.PendingPayments)
                                       .Without(p => p.Payments)
                                       .Create();

            _pendingPayments = new List <PendingPayment>
            {
                _fixture.Build <PendingPayment>()
                .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                .With(p => p.PeriodNumber, (byte?)2)      // current period
                .With(p => p.PaymentYear, (short?)2021)
                .With(p => p.DueDate, DateTime.Parse("2020-09-09"))
                .With(p => p.ClawedBack, false)
                .With(p => p.EarningType, EarningType.FirstPayment)
                .Without(p => p.PaymentMadeDate)
                .Create(),
                _fixture.Build <PendingPayment>()
                .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                .With(p => p.PeriodNumber, (byte?)2)      // future period
                .With(p => p.PaymentYear, (short?)2122)
                .With(p => p.DueDate, DateTime.Parse("2021-10-07"))
                .With(p => p.ClawedBack, false)
                .With(p => p.EarningType, EarningType.SecondPayment)
                .Without(p => p.PaymentMadeDate)
                .Create()
            };

            _apprenticeshipIncentive.PendingPayments = _pendingPayments;

            _payments = new List <Payment>
            {
                _fixture.Build <Payment>()
                .With(p => p.ApprenticeshipIncentiveId, _apprenticeshipIncentive.Id)
                .With(p => p.PendingPaymentId, _pendingPayments.First().Id)
                .With(p => p.AccountId, _apprenticeshipIncentive.AccountId)
                .With(p => p.AccountLegalEntityId, _apprenticeshipIncentive.AccountLegalEntityId)
                .Create(),
            };

            _apprenticeshipIncentive.Payments = _payments;
        }
コード例 #4
0
        public ActionResult Verify(Data.Models.Account model)
        {
            model.ID = Request.Url.Segments.Last();
            model    = DataAccess.Account.VerifyAccount(model);
            if (model == null)
            {
                return(View("ResetPassword"));
            }

            FormsAuthentication.SetAuthCookie(model.Username.ToLower(), false);

            return(RedirectToAction("Disclaimer"));
        }
コード例 #5
0
        public ActionResult Verify(string id)
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                FormsAuthentication.SignOut();
            }

            Data.Models.Account act = DataAccess.Account.GetAccountByAccountId(Guid.Parse(id));

            if (act == null || act.DateCreatedTimestamp != act.LastUpdateTimestamp)
            {
                return(Redirect("/"));
            }

            return(View("ResetPassword"));
        }
コード例 #6
0
ファイル: UserHelper.cs プロジェクト: jochemstoel/EPONS
        internal static Data.Models.UpdateResult SaveProfile(Data.Models.Account account)
        {
            if (account.Avatar != null)
            {
                if (account.Avatar == DefaultAvatar)
                {
                    account.Avatar = null;
                }
                else if (!(account.Avatar.Substring(0, 22) == "data:image/png;base64,"))
                {
                    account.Avatar = null;
                }
            }

            return(Data.DataAccess.Account.Update(account, Username));
        }
コード例 #7
0
 public dynamic SetDisabled(Data.Models.Account account)
 {
     try
     {
         AccountBLL bll = new AccountBLL();
         bll.SetDisabled(account.Id, account.IsDisabled);
         return(new { status = 0 });
     }
     catch (ErrorMsgException ex)
     {
         return(new { status = ex.Status, message = ex.Message });
     }
     catch (Exception ex)
     {
         return(new { status = 500, message = ex.Message });
     }
 }
コード例 #8
0
        public JsonResult AccreditationList()
        {
            List <Models.Accreditation> output = null;

            ReturnTrue.Utilities.Shared.JsonClient.Execute <List <Models.Accreditation> >(
                HttpMethod.Get,
                new Uri(string.Format("https://sadfm.co.za/trainingSADFM/grading_report.php?startdate={0}", new DateTime(1900, 1, 1).ToString("yyyy-MM-dd"))),
                result =>
            {
                var dbAccounts = DataAccess.Account.GetAllAccounts();
                result.ForEach(a =>
                {
                    a.GradeDisplay = a.Grade.ToString("0.0#");

                    Data.Models.Account account = dbAccounts.SingleOrDefault(ax => ax.Username.ToLower() == a.Username.ToLower());
                    if (account == null)
                    {
                        account = dbAccounts.SingleOrDefault(ax => ax.EmailAddress.ToLower() == a.EmailAddress.ToLower());
                    }
                    if (account == null)
                    {
                        a.UserMatched = false;
                        return;
                    }
                    a.UserMatched = true;
                });
                output = result;
            },
                failure =>
            {
                throw new ApplicationException("Cannot connect to Moodle");
            });


            output = output.GroupBy(x => x.Username).Select(x => x.OrderByDescending(y => y.GradeTimestamp).FirstOrDefault()).ToList();

            return(Json(
                       Utilities.DataTableJson(
                           Utilities.DataTableRequest.Parse(Request.Form),
                           output,
                           null,
                           x => x.Username, x => x.EmailAddress, x => x.GradeDisplay, x => x.ScaleCode, x => x.UserMatched, x => x.GradeTimestamp, x => x.Grade)));
        }
コード例 #9
0
 public dynamic Post(Data.Models.Account account)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             string msg = ModelState.Values.First().Errors[0].ErrorMessage;
             return(new { status = 1, message = msg });
         }
         AccountBLL bll = new AccountBLL();
         bll.Save(account);
         return(new { status = 0 });
     }
     catch (ErrorMsgException ex)
     {
         return(new { status = ex.Status, message = ex.Message });
     }
     catch (Exception ex)
     {
         return(new { status = 500, message = ex.Message });
     }
 }
コード例 #10
0
ファイル: Account.cs プロジェクト: kamal622/ProAccount
 private void assignFormFieldsData(Data.Models.Account accountData)
 {
     try
     {
         accountId = accountData.Id;
         comboFirm.SelectedValue        = accountData.FirmId;
         comboAccountType.SelectedValue = accountData.AccountTypes;
         txtAccountName.Text            = accountData.ContactName;
         txtMobileNo.Text        = accountData.ContactNo;
         txtFindAccountName.Text = accountData.ContactName;
         txtAccountCode.Text     = accountData.AccountCode;
         txtAddress.Text         = accountData.Address;
         txtEmail.Text           = accountData.Email;
         txtOpeningCredit.Text   = accountData.OpeningCredit.ToString();
         txtOpeningDebit.Text    = accountData.OpeningDebit.ToString();
         // btnAccountDelete.Enabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Comman.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #11
0
 public void SaveAccount(Data.Models.Account accountData)
 {
     using (Data.Models.ProAccountContext db = new Data.Models.ProAccountContext())
     {
         if (accountData.Id > 0)
         {
             var data = db.Accounts.FirstOrDefault(W => W.Id == accountData.Id);
             if (data != null)
             {
                 data.FirmId        = accountData.FirmId;
                 data.ContactName   = accountData.ContactName;
                 data.ContactNo     = accountData.ContactNo;
                 data.AccountCode   = accountData.AccountCode;
                 data.AccountTypes  = accountData.AccountTypes;
                 data.Address       = accountData.Address;
                 data.Email         = accountData.Email;
                 data.OpeningCredit = accountData.OpeningCredit;
                 data.OpeningDebit  = accountData.OpeningDebit;
                 db.SaveChanges();
             }
         }
         else
         {
             db.Accounts.Add(new Data.Models.Account {
                 FirmId        = accountData.FirmId,
                 ContactName   = accountData.ContactName,
                 ContactNo     = accountData.ContactNo,
                 AccountCode   = accountData.AccountCode,
                 AccountTypes  = accountData.AccountTypes,
                 Address       = accountData.Address,
                 Email         = accountData.Email,
                 OpeningCredit = accountData.OpeningCredit,
                 OpeningDebit  = accountData.OpeningDebit
             });
             db.SaveChanges();
         }
     }
 }
コード例 #12
0
ファイル: Account.cs プロジェクト: kamal622/ProAccount
        private void btnAccountSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateAccountFields())
                {
                    accountService = new AccountService();

                    var    firId       = comboFirm.SelectedValue;
                    string Name        = txtAccountName.Text;
                    string MobileNo    = txtMobileNo.Text;
                    string accountCode = txtAccountCode.Text;
                    int    firmId      = Convert.ToInt32(firId);
                    int    AccountType = Convert.ToInt32(comboAccountType.SelectedValue);

                    Data.Models.Account accounData = new Data.Models.Account();
                    accounData.Id            = accountId;
                    accounData.ContactName   = Name;
                    accounData.ContactNo     = MobileNo;
                    accounData.FirmId        = firmId;
                    accounData.AccountTypes  = AccountType;
                    accounData.AccountCode   = accountCode;
                    accounData.Address       = txtAddress.Text;
                    accounData.OpeningCredit = Convert.ToDecimal(txtOpeningCredit.Text);
                    accounData.OpeningDebit  = Convert.ToDecimal(txtOpeningDebit.Text);
                    accounData.Email         = txtEmail.Text;

                    accountService.SaveAccount(accounData);
                    ClearAccountFieldsValues();
                    MessageBox.Show("Account added", Comman.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Comman.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #13
0
        /// <summary>
        /// 保存cookie
        /// </summary>
        /// <param name="user"></param>
        /// <param name="token"></param>
        protected void SaveCookie(IAuthIdentity user, TokenModel token)
        {
            Data.Models.Account account = user.GetUser() as Data.Models.Account;
            //添加token到
            HttpCookie cookie = new HttpCookie("token", token.Token);

            cookie.Expires = DateTime.Now.AddHours(2);
            HttpContext.Current.Response.Cookies.Add(cookie);

            //添加refreshToken和token的失效时间,失效时间为100分钟
            DateTime validDatetime = DateTime.UtcNow.AddMinutes(100);
            var      refresh       = new
            {
                refreshToken = token.RefreshToken,
                vaildTime    = Common.Timestamp.GetTimestamp(validDatetime).ToString(),
                userId       = account.Id,
                userType     = account.Type
            };

            HttpCookie refreshcookie = new HttpCookie("refresh", JsonHelper.Serialize(refresh));

            refreshcookie.Expires = DateTime.Now.AddHours(2);
            HttpContext.Current.Response.Cookies.Add(refreshcookie);
        }
コード例 #14
0
        public JsonResult DeceasedList()
        {
            Utilities.DataTableRequest dataTableRequest = Utilities.DataTableRequest.Parse(Request.Form);
            int count;

            Data.Models.Account act = UserHelper.GetCurrentAccount();

            string query = dataTableRequest.search;

            var result = _patientService.ListDeceasedPatients(act.Username, out count, (dataTableRequest.start / dataTableRequest.length) + 1, dataTableRequest.length, query, "Firstname", true);

            dataTableRequest.OverrideSearch        = true;
            dataTableRequest.OverrideCount         = count;
            dataTableRequest.OverrideFilteredCount = count;
            return(Json(
                       Utilities.DataTableJson(
                           dataTableRequest,
                           result.Select(x => new
            {
                FirstName = x.Firstname,
                LastName = x.Lastname,
                BirthDate = x.DateOfBirth.HasValue ? string.Format("{0} ({1})", x.DateOfBirth.Value.ToString("dd MMM yyyy"), Convert.ToInt32(DateTime.Now.Subtract(x.DateOfBirth.Value).TotalDays / 365)) : string.Empty,
                Gender = x.Gender == null ? string.Empty : x.Gender.Name,
                Race = x.Race == null ? string.Empty : x.Race.Name,
                MedicalScheme = x.MedicalScheme == null ? string.Empty : x.MedicalScheme.Name,
                IDNumber = x.Details == null ? string.Empty : x.Details.IdentificationNumber,
                GenderID = x.Gender == null ? string.Empty : x.Gender.Id.ToString(),
                RaceID = x.Race == null ? string.Empty : x.Race.Id.ToString(),
                Age = string.Empty,
                ID = x.Id,
                PatientId = x.Id.ToString("N"),
                Providers = string.Join(", ", x.TeamMembers.GroupBy(y => y.Facility.Id).Select(y => y.First().Facility.Name))
            }).ToList(),
                           null,
                           x => x.FirstName, x => x.LastName, x => x.BirthDate, x => x.Gender, x => x.Race, x => x.Providers, x => x.MedicalScheme, x => x.ID, x => x.Age, x => x.GenderID, x => x.RaceID, x => x.PatientId)));
        }
コード例 #15
0
 public JsonResult SaveProfile(Data.Models.Account account)
 {
     return(Json(UserHelper.SaveProfile(account)));
 }
コード例 #16
0
 public ServiceResponse <Data.Models.Account> UpdateAccount(Data.Models.Account account)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            Data.Models.Account account = UserHelper.GetCurrentAccount();

            if (account != null)
            {
                if (account.DisclaimerAgreeTimestamp == null)
                {
                    filterContext.Result = new RedirectResult("/Account/Disclaimer");
                    return;
                }
            }

            if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                filterContext.Result = new RedirectResult(FormsAuthentication.LoginUrl);
                return;
            }

            if (account != null)
            {
                if (account.FirstSignIn && !filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery.ToLower().EndsWith("/account/profile") && !filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery.ToLower().EndsWith("/account/saveprofile") && !filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery.ToLower().EndsWith("/account/logout"))
                {
                    filterContext.Result = new RedirectResult("/Account/Profile");
                    return;
                }
            }
            else
            {
                filterContext.Result = new RedirectResult("/Account/Login");
                return;
            }

            /*
             * bool allowed = false;
             * if (AllowedPermissions.Length != 0)
             * {
             *  Data.Models.Account account = UserHelper.GetCurrentAccount();
             *  allowed = AllowedPermissions.Contains(account.Role);
             * }
             * else
             *  allowed = true;
             * if (!allowed)
             * {
             *  filterContext.Result = new RedirectResult(FormsAuthentication.DefaultUrl);
             *  return;
             * }
             *
             *
             * if (account.AccountType != "SuperAdmin")
             * {
             *  if (!UserHelper.SelectedClientId.HasValue)
             *      if (!filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery.ToLower().EndsWith("/account/multipleproviders")) {
             *          var tmp = account.Permissions.Select(p => p.GetClientId()).Distinct();
             *          if (tmp.Count() == 1)
             *               UserHelper.SetSelectedClientId(tmp.First());
             *  }
             *  if (!UserHelper.SelectedClientId.HasValue)
             *  {
             *      filterContext.Result = new RedirectResult("/Account/MultipleProviders");
             *      return;
             *  }
             * }
             *
             */

            base.OnAuthorization(filterContext);
        }
コード例 #18
0
        public JsonResult NewCase(ViewModels.Case model)
        {
            string ICD10 = model.ICD10ID.Split(' ')[0];

            SADFM.Data.Models.ListItem icd10_ListItem = SADFM.Data.DataAccess.ListItem.GetList("ICD10", filter: li => li.Name == ICD10).FirstOrDefault();
            if (icd10_ListItem == null)
            {
                return(Json(new { Success = false, Error = "Cannot find ICD" }));
            }

            if (model.CaseId == null)
            {
                Data.Models.Account account = UserHelper.GetCurrentAccount();
                Guid accountId = account.GetId();

                SADFM.Data.Case caseObject = new SADFM.Data.Case()
                {
                    ICD10Id = icd10_ListItem.GetId(),
                    CaseId  = Guid.NewGuid(),
                    DateCreatedTimestamp = DateTime.Now,
                    LastUpdateTimestamp  = DateTime.Now,
                    StartDate            = model.StartDate,
                    EndDate             = model.EndDate,
                    PatientId           = SADFM.Data.Models.BaseModel.DecryptId(model.PatientId),
                    LastUpdateAccountId = UserHelper.GetCurrentAccount().GetId(),
                    ImpairmentGroupId   = model.ImpairmentGroupId != null?BaseModel.DecryptNullableId(model.ImpairmentGroupId) : null,
                                              ReferringDoctor               = model.ReferringDoctor,
                                              ReferringDoctorContact        = model.ReferringDoctorContact,
                                              ReferringDoctorEmail          = model.ReferringDoctorEmail,
                                              ReferringDoctorPracticeNumber = model.ReferringDoctorPracticeNumber,
                                              TreatingDoctor               = model.TreatingDoctor,
                                              TreatingDoctorContact        = model.TreatingDoctorContact,
                                              TreatingDoctorEmail          = model.TreatingDoctorEmail,
                                              TreatingDoctorPracticeNumber = model.TreatingDoctorPracticeNumber,
                                              AdmissionStatusId            = SADFM.Data.Models.BaseModel.DecryptNullableId(model.AdmissionStatusId)
                };



                if (UserHelper.GetCurrentAccount().Permissions.Count(x => x.GetClientId() == UserHelper.SelectedClientId && (x.PermissionDescription.Equals("Clinician"))) != 0)
                {
                    caseObject.PatientProviders.Add(new Data.PatientProvider()
                    {
                        AccountId           = UserHelper.GetCurrentAccount().GetId(),
                        AssignedTimestamp   = DateTime.Now,
                        CreatedTimestamp    = DateTime.Now,
                        LastUpdateAccountId = UserHelper.GetCurrentAccount().GetId(),
                        LastUpdateTimestamp = DateTime.Now,
                        ProviderId          = UserHelper.SelectedClientId.Value,
                        PatientProviderId   = Guid.NewGuid(),
                        PatientId           = SADFM.Data.Models.BaseModel.DecryptId(model.PatientId)
                    });
                }

                DataAccess.Account.AddCase(caseObject, UserHelper.GetCurrentAccount().GetId());

                return(Json(new
                {
                    Success = true,
                    Id = caseObject.CaseId.ToString("N")
                }));
            }
            else
            {
                return(Json(DataAccess.Account.UpdateCase(new Data.Case()
                {
                    CaseId = Data.Models.BaseModel.DecryptId(model.CaseId),
                    StartDate = model.StartDate,
                    EndDate = model.EndDate,
                    ICD10Id = icd10_ListItem.GetId(),
                    PatientId = Data.Models.BaseModel.DecryptId(model.PatientId),
                    ImpairmentGroupId = model.ImpairmentGroupId != null ? BaseModel.DecryptNullableId(model.ImpairmentGroupId) : null,
                    ReferringDoctor = model.ReferringDoctor,
                    ReferringDoctorContact = model.ReferringDoctorContact,
                    ReferringDoctorEmail = model.ReferringDoctorEmail,
                    ReferringDoctorPracticeNumber = model.ReferringDoctorPracticeNumber,
                    TreatingDoctor = model.TreatingDoctor,
                    TreatingDoctorContact = model.TreatingDoctorContact,
                    TreatingDoctorEmail = model.TreatingDoctorEmail,
                    TreatingDoctorPracticeNumber = model.TreatingDoctorPracticeNumber,
                    AdmissionStatusId = SADFM.Data.Models.BaseModel.DecryptNullableId(model.AdmissionStatusId)
                }, UserHelper.GetCurrentAccount().GetId())));
            }
        }
コード例 #19
0
        public JsonResult NewPatient(ViewModels.Patient model)
        {
            Data.Models.Account account = UserHelper.GetCurrentAccount();
            Guid accountId = account.GetId();

            try
            {
                Data.Patient patient = new Data.Patient()
                {
                    ResidentialEnvironmentId = SADFM.Data.Models.BaseModel.DecryptNullableId(model.ResidentialEnvironmentID),
                    AdmitFromId                   = SADFM.Data.Models.BaseModel.DecryptNullableId(model.AdmitFromID),
                    Street                        = model.Street,
                    DischargeToId                 = SADFM.Data.Models.BaseModel.DecryptNullableId(model.DischargeToID),
                    FirstName                     = model.FirstName,
                    PatientId                     = Guid.NewGuid(),
                    LastName                      = model.LastName,
                    DateCreatedTimestamp          = DateTime.Now,
                    LastUpdateTimestamp           = DateTime.Now,
                    LastUpdateAccountId           = accountId,
                    IDNumber                      = model.IDNumber,
                    ContactNumber                 = model.ContactNumber,
                    ProvinceId                    = SADFM.Data.Models.BaseModel.DecryptNullableId(model.ProvinceId),
                    CityId                        = SADFM.Data.Models.BaseModel.DecryptNullableId(model.CityId),
                    PostalCode                    = model.PostalCode,
                    NextOfKinName                 = model.NextOfKinName,
                    NextOfKinContact              = model.NextOfKinContact,
                    NextOfKinEmail                = model.NextOfKinEmail,
                    NextOfKinRelationship         = model.NextOfKinRelationship,
                    RaceId                        = SADFM.Data.Models.BaseModel.DecryptNullableId(model.RaceID),
                    GenderId                      = SADFM.Data.Models.BaseModel.DecryptNullableId(model.GenderID),
                    BirthDate                     = Convert.ToDateTime(model.BirthDate),
                    TitleId                       = SADFM.Data.Models.BaseModel.DecryptNullableId(model.TitleId),
                    CountryId                     = SADFM.Data.Models.BaseModel.DecryptNullableId(model.CountryID),
                    MedicalSchemeMembershipNumber = model.MedicalSchemeNo,
                    PatientSupportServices        = model.SupportServices != null?model.SupportServices.Select(x => new Data.PatientSupportService()
                    {
                        SupportServiceId     = x.SupportServiceId,
                        Note                 = x.Note,
                        LastUpdatedTimestamp = DateTime.Now,
                        LastUpdatedAccountId = UserHelper.GetCurrentAccount().GetId()
                    }).ToList() : null
                };

                if (model.MedicalSchemeID != null)
                {
                    patient.MedicalSchemeId = SADFM.Data.Models.BaseModel.DecryptId(model.MedicalSchemeID);
                }
                DataAccess.Account.AddPatient(patient, accountId);


                if (UserHelper.SelectedClientId.HasValue)
                {
                    bool hasClosedCase;
                    Guid?caseId;
                    DataAccess.Patient.AddPatientProvider(new Data.Models.PatientProvider()
                    {
                        AssignedTimestamp   = DateTime.Now,
                        DischargedTimestamp = null,
                        ProviderId          = BaseModel.EncryptId(UserHelper.SelectedClientId.Value),
                        CaseId            = null,
                        AccountID         = BaseModel.EncryptId(accountId),
                        PatientId         = BaseModel.EncryptId(patient.PatientId),
                        PatientProviderID = null
                    }, accountId, out hasClosedCase, out caseId);
                }
                return(Json(new
                {
                    Success = true,
                    Id = patient.PatientId.ToString("N"),
                    Guid = patient.PatientId.ToString()
                }));
            }
            catch (Exception e)
            {
                SADFM.Base.NLogHelper.WriteEvent(NLog.LogLevel.Info, "PatientController.NewPatient" + " ->> " + "Account: " + account.Username + "\r\n" + e.Message);
                return(Json(new
                {
                    Success = false,
                    Message = "Error has occurred."
                }));
            }
        }
コード例 #20
0
        public ActionResult Login(Models.Login login)
        {
            if (!Utilities.ConfirmSecurity(login.Security))
            {
                return(View());
            }

            SADFM.Base.NLogHelper.WriteEvent(NLog.LogLevel.Info, "AccountController.Login:Start");

            Response.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
            Response.AddHeader("Expires", "Fri, 01 Jan 1990 00:00:00 GMT");
            Response.AddHeader("Pragma", "no-cache");

            SADFM.Base.NLogHelper.WriteEvent(NLog.LogLevel.Info, "AccountController.Login:  - UserHelper.GetAccount");
            Data.Models.Account account = UserHelper.GetAccount(login.Username);
            SADFM.Base.NLogHelper.WriteEvent(NLog.LogLevel.Info, "AccountController.Login:  - UserHelper.GetAccount done");


            if (account == null)
            {
                ViewBag.LoginErrorMessage = Library.GetText("InvalidLoginText");
                ViewBag.Username          = login.Username;

                return(View());
            }

            bool hasmultipleproviders = false;

            /*
             * //has password expired
             * DateTime PasswordDate = account.LastUpdateTimestamp;
             * DateTime ComparisonDate = DateTime.Today;
             * TimeSpan difference = ComparisonDate - PasswordDate;
             * if (difference.TotalDays >= 90)
             * {
             *  return Redirect("/Account/ResetPassword?User="******"&Providers=true");
             * }
             *
             */

            //first login?
            try
            {
                SADFM.Base.NLogHelper.WriteEvent(NLog.LogLevel.Info, "AccountController.Login:  - UserHelper.DataAccess.Account.Validate");
                if (DataAccess.Account.Validate(login.Username, login.Password) == "Active")
                {
                    FormsAuthentication.SetAuthCookie(login.Username.ToLower(), login.RememberMe);

                    if (account.FirstSignIn)
                    {
                        return(Redirect("/Account/ResetPassword?User="******"&Providers=" + hasmultipleproviders));
                    }
                    else if (account.ResetBySuperAdmin)
                    {
                        return(Redirect("/Account/Disclaimer?User="******"&Providers=" + hasmultipleproviders));
                    }

                    List <Guid> clients = account.Permissions.Select(kvp => kvp.GetClientId()).Distinct().ToList();

                    if (clients.Count < 2)
                    {
                        if (clients.Count == 1)
                        {
                            UserHelper.SetSelectedClientId(login.Username.ToLower(), clients[0]);
                        }
                        return(Redirect(FormsAuthentication.DefaultUrl));
                    }
                    else
                    {
                        return(Redirect("/Account/MultipleProviders?User="******"&Providers=" + hasmultipleproviders));
                    }
                }
                else
                {
                    ViewBag.LoginErrorMessage = Library.GetText("InvalidLoginText");
                    ViewBag.Username          = login.Username;
                    ViewBag.MultipleProviders = hasmultipleproviders;
                    if (hasmultipleproviders)
                    {
                        Models.ManageUserViewModel manageuser = new Models.ManageUserViewModel();

                        manageuser.Username               = login.Username;
                        ViewBag.MultipleProviders         = hasmultipleproviders;
                        manageuser.MultipleProviderMember = ViewBag.MultipleProviders;
                        ViewBag.UserName = login.Username;
                        return(Redirect("/Account/MultipleProviders?User="******"&Providers=" + hasmultipleproviders));
                    }
                    else
                    {
                        return(View());
                    }
                }
            }
            finally
            {
                SADFM.Base.NLogHelper.WriteEvent(NLog.LogLevel.Info, "AccountController.Login:  - UserHelper.DataAccess.Account.Validate Done");
            }
        }
コード例 #21
0
        public ActionResult Reset(Models.ManageUserViewModel model, string oldpassword, string HiddenNewPassword, string securityquestion, string securityanswer, string hdnusername, string chkconfirmagree, string HiddenchkAgree, string hdnfrom, string accountid, string multiple)
        {
            bool hasmultiple = false;

            if (multiple != null)
            {
                if (multiple == "True")
                {
                    hasmultiple = true;
                }
                ViewBag.MultipleProviders = "True";
            }
            if (hdnfrom == "securityquestion")
            {
                //check correct answer
                string answer = DataAccess.Account.GetAccountSecurityAnswer(hdnusername);
                if (answer.ToLower() == securityanswer.ToLower())
                {
                    return(Redirect("/Account/Reset?User="******"&chkconfirmagree=" + chkconfirmagree + "&chkagree=" + HiddenchkAgree + "&Provider=" + hasmultiple));
                }
                else
                {
                    return(Redirect("/Account/SecurityQuestion?User="******"&chkconfirmagree=" + chkconfirmagree + "&chkagree=" + HiddenchkAgree + "&Provider=" + hasmultiple + "&Msg=wrong"));
                }
            }
            else
            {
                string username = string.Empty;
                if (Request.QueryString.HasKeys())
                {
                    List <string> keys = new List <string>(Request.QueryString.AllKeys);
                    if (keys.Contains("User") && Request.QueryString["User"].Length > 0)
                    {
                        username = Request.QueryString["User"];
                    }
                    if (keys.Contains("Provider") && Request.QueryString["Provider"].Length > 0)
                    {
                        if (Request.QueryString["Provider"] == "True")
                        {
                            hasmultiple = true;
                        }
                        ViewBag.MultipleProviders = hasmultiple;
                    }
                }
                else
                {
                    username = model.Username;
                }

                Models.ManageUserViewModel manageuser = new Models.ManageUserViewModel();
                manageuser.OldPassword            = oldpassword;
                manageuser.MultipleProviderMember = hasmultiple;
                manageuser.NewPassword            = HiddenNewPassword;
                manageuser.Username         = hdnusername;
                manageuser.SecurityQuestion = securityquestion;
                manageuser.SecurityAnswer   = securityanswer;

                bool success = DataAccess.Account.ResetUserPassword(manageuser.NewPassword, manageuser.Username, securityquestion, securityanswer, accountid, Guid.NewGuid());
                Data.Models.Account thisaccount = new Data.Models.Account();
                thisaccount.Username = manageuser.Username;
                thisaccount          = DataAccess.Account.GetAccountByUsername(manageuser.Username);
                if (success)
                {
                    return(View("Profile", thisaccount));
                }
                else
                {
                    return(View("ResetPassword"));
                }
            }
        }
コード例 #22
0
        public ActionResult ResetPassword(Models.ManageUserViewModel model, string oldpassword, string HiddenNewPassword, string securityquestion, string SecurityQuestionID, string SecurityQuestionAnswer, string hdnusername, string chkconfirmagree, string HiddenchkAgree, string accountid, string multiple)
        {
            bool hasmultiple = false;

            if (multiple != null)
            {
                if (multiple == "True")
                {
                    hasmultiple = true;
                }
                ViewBag.MultipleProviders = "True";
            }
            if (chkconfirmagree == "on" && HiddenchkAgree == "on")
            {
                return(Redirect("/Account/Reset?User="******"&chkconfirmagree=" + chkconfirmagree + "&chkagree=" + HiddenchkAgree + "&Provider=" + hasmultiple));
            }
            string username = string.Empty;

            if (Request.QueryString.HasKeys())
            {
                List <string> keys = new List <string>(Request.QueryString.AllKeys);
                if (keys.Contains("User") && Request.QueryString["User"].Length > 0)
                {
                    username = Request.QueryString["User"];
                }
                if (keys.Contains("Provider") && Request.QueryString["Provider"].Length > 0)
                {
                    if (Request.QueryString["Provider"] == "True")
                    {
                        hasmultiple = true;
                    }
                    ViewBag.MultipleProviders = "True";
                }
            }
            if (accountid == null)
            {
                accountid = string.Empty;
            }
            Guid securityquestionid = new Guid();

            if (SecurityQuestionID != null)
            {
                securityquestionid = SADFM.Data.Models.BaseModel.DecryptId(SecurityQuestionID);
                securityquestion   = DataAccess.ListItem.GetListItemDescriptionByName(securityquestionid);
            }
            Models.ManageUserViewModel manageuser = new Models.ManageUserViewModel();
            manageuser.OldPassword            = oldpassword;
            manageuser.NewPassword            = HiddenNewPassword;
            manageuser.Username               = hdnusername;
            manageuser.SecurityQuestion       = securityquestion;
            manageuser.SecurityAnswer         = SecurityQuestionAnswer;
            manageuser.MultipleProviderMember = hasmultiple;
            //
            bool success = DataAccess.Account.ResetUserPassword(manageuser.NewPassword, manageuser.Username, securityquestion, SecurityQuestionAnswer, accountid, securityquestionid);

            Data.Models.Account thisaccount = new Data.Models.Account();
            thisaccount.Username = manageuser.Username;

            thisaccount = DataAccess.Account.GetAccountByUsername(manageuser.Username);
            if (success)
            {
                return(View("Login"));
            }
            else
            {
                return(View("ResetPassword"));
            }
        }