Exemplo n.º 1
0
        public void CanAddUser()
        {
            var repo = new UserRepository();
            var user = new User
                           {
                               Username = "******",
                               Password = "******",
                               EmailAddress = "*****@*****.**",
                               FirstName = "Matthew",
                               MiddleName = "Scott",
                               LastName = "Kimber",
                               PhoneNumber = "222-1234567",
                               IsActive = true,
                               LicenseNumber = "ABCDEFG123",
                               StaffType = StaffType.Physician,
                               Address = new Address
                                             {
                                                 Street1 = "939 E. 490 N.",
                                                 Street2 = "Apt. 1B",
                                                 City = "Ogden",
                                                 Region = "Utah",
                                                 //Country = "USA",
                                                 IsActive = true
                                             },
                               DateCreated = DateTime.Now,
                               IsApproved = true
                           };

            repo.Add(user);

            UnitOfWork.CurrentSession.Flush();
            UnitOfWork.CurrentSession.Clear();

            var retrievedUser = repo.Get("matthew.kimber");

            Assert.AreEqual(user.Username, retrievedUser.Username);
        }
 /// <summary>
 /// Create MembershipUser from User
 /// </summary>
 /// <param name="user">User to create a membershipUser from</param>
 /// <returns></returns>
 private static MembershipUser TransformUser(User user)
 {
     return new MembershipUser("OpenEhsMembershipProvider",
                               user.Username,
                               null,
                               user.EmailAddress,
                               user.PasswordQuestion,
                               String.Empty,
                               user.IsApproved,
                               user.IsLockedOut,
                               user.DateCreated,
                               user.LastLogin,
                               user.LastActivity,
                               user.LastPasswordChange,
                               DateTime.MinValue);
 }
 public UserDetailsViewModel(User user)
 {
     _user = user;
 }
Exemplo n.º 4
0
        public JsonResult AddNote()
        {
            try
            {
                PatientRepository patientRepo = new PatientRepository();
                UserRepository userRepo = new UserRepository();
                User staff = new User();

                if (Request.Form["StaffId"] != "")
                    staff = userRepo.Get(int.Parse(Request.Form["StaffId"]));

                Patient patient = patientRepo.Get(int.Parse(Request.Form["PatientId"]));

                Note note = new Note();

                var query = from checkin in patient.PatientCheckIns
                            where checkin.CheckOutTime == DateTime.MinValue
                            select checkin;
                PatientCheckIn openCheckIn = query.First<PatientCheckIn>();
                note.Author = staff;
                note.DateCreated = DateTime.Now;
                note.Body = Request.Form["NoteBody"]; //HttpUtility.UrlDecode(Request.Form["NoteBody"], System.Text.Encoding.Default);
                note.PatientCheckIns = openCheckIn;
                note.Title = "";
                note.Type = NoteType.General;
                note.IsActive = true;
                openCheckIn.Notes.Add(note);

                if (Request.Form["TemplateTitle"] != null && Request.Form["TemplateTitle"] != "")
                {
                    TemplateRepository templateRepo = new TemplateRepository();
                    NoteTemplateRepository noteRepo = new NoteTemplateRepository();
                    NoteTemplateCategory noteCat = noteRepo.Get(1);
                    Template template = new Template();
                    template.Title = Request.Form["TemplateTitle"];
                    template.Staff = staff;
                    template.Body = note.Body;
                    template.IsActive = true;
                    template.NoteTemplateCategory = noteCat;
                    templateRepo.Add(template);
                    return Json(new
                    {
                        templateId = template.Id,
                        templateTitle = template.Title,
                        NoteBody = note.Body,
                        error = "false"
                    });
                }
                return Json(new
                {
                    NoteBody = note.Body,
                    error = "false"
                });
            }
            catch
            {
                return Json(new
                {
                    error = "true"
                });
            }
        }