public int Save(NurseModel nurse)
        {
            query = "INSERT INTO NurseTable " +
                    "VALUES(@firstName,@lastName,@address," +
                    "@dateOfJoining,@NID ) ";

            Command = new SqlCommand(query, Connection);

            Command.Parameters.AddWithValue("@firstName", nurse.FirstName);
            Command.Parameters.AddWithValue("@lastName", nurse.LastName);

            Command.Parameters.AddWithValue("@address", nurse.Address);


            Command.Parameters.AddWithValue("@dateOfJoining", nurse.DateOfJoining);

            Command.Parameters.AddWithValue("@NID", nurse.NID);


            Connection.Open();
            int rowEffect = Command.ExecuteNonQuery();

            Connection.Close();

            return(rowEffect);
        }
        //-------show Nurse------------------------------------

        public List <NurseModel> GetAllNurse()
        {
            query = "SELECT * FROM NurseTable";

            Command = new SqlCommand(query, Connection);
            List <NurseModel> nurseList = new List <NurseModel>();

            Connection.Open();
            Reader = Command.ExecuteReader();

            while (Reader.Read())
            {
                NurseModel nurse = new NurseModel();


                nurse.FirstName = Reader["FirstName"].ToString();
                nurse.LastName  = Reader["LastName"].ToString();
                nurse.Address   = Reader["Address"].ToString();
                nurse.NID       = Convert.ToInt32(Reader["NID"]);



                nurseList.Add(nurse);
            }
            Connection.Close();
            return(nurseList);
        }
Exemplo n.º 3
0
        public string Save(NurseModel nurse)
        {
            int rowEffect = nurseGateway.Save(nurse);

            if (rowEffect > 0)
            {
                return("Save Successful");
            }
            else
            {
                return("Save Faild");
            }
        }
        // GET: Nurse/Create
        public IActionResult Create()
        {//10/10/2019 aakansha
            ViewBag.FormName = "Nurse";
            if (!(bool)SharedData.isNurseMenuAccessible)
            {
                return(AccessDeniedView());
            }
            var nurse = new NurseModel();

            nurse.NurseDocuments = new List <NurseDocuments>();

            return(View(nurse));
        }
Exemplo n.º 5
0
        public override void Handle()
        {
            Console.Clear();
            Console.WriteLine("LISTING ALL USERS");
            Dictionary <int, User> users   = new UserModel().GetAllUsers().ToDictionary(user => user.Id);
            List <Admin>           admins  = new AdminModel().GetAllAdmins().ToList();
            List <Nurse>           nurses  = new NurseModel().GetAllNurses().ToList();
            List <Doctor>          doctors = new DoctorModel().GetAllDoctors().ToList();

            Console.WriteLine("ADMINS");
            var tableAdmin = new ConsoleTable("#", "Last name", "First name", "PESEL", "Username");

            foreach (var admin in admins)
            {
                var currentUser = users[admin.UserId];
                tableAdmin.AddRow(currentUser.Id, currentUser.Lastname, currentUser.Firstname, currentUser.Pesel, currentUser.Username);
            }
            tableAdmin.Write(Format.Alternative);

            var tableNurse = new ConsoleTable("#", "Last name", "First name", "PESEL", "Username");

            Console.WriteLine("NURSES");
            foreach (var nurse in nurses)
            {
                var currentUser = users[nurse.UserId];
                tableNurse.AddRow(currentUser.Id, currentUser.Lastname, currentUser.Firstname, currentUser.Pesel, currentUser.Username);
            }
            tableNurse.Write(Format.Alternative);

            Console.WriteLine("DOCTORS");
            var tableDoctor = new ConsoleTable("#", "Last name", "First name", "PESEL", "Username", "Speciality", "PWZ");

            foreach (var doctor in doctors)
            {
                var currentUser = users[doctor.UserId];
                tableDoctor.AddRow(currentUser.Id, currentUser.Lastname, currentUser.Firstname, currentUser.Pesel, currentUser.Username, doctor.Speciality, doctor.Pwz);
            }
            tableDoctor.Write(Format.Alternative);

            Console.WriteLine("If you want to see user's calendar type ID here (leave blank to exit): ");
            int input = 0;

            if (int.TryParse(Console.ReadLine(), out input) && input > 0)
            {
                new UsersCalendar().Handle(input);
            }
        }
        public ActionResult ManageNurses(NurseModel nurseUpdates)
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api adminApi = new Admin_Api();

            var model = adminApi.UpdateNurse(nurseUpdates);

            if (model != null)
            {
                return(View("~/Views/Administrator/AdminViewNurses.cshtml", model));
            }
            return(View("~/Views/Error.cshtml"));
        }
Exemplo n.º 7
0
        public ActionResult EditProfile()
        {
            using (var db = new MainDbContext())
            {

                string firstname = User.Identity.Name;
                var NurseModel = db.Nurse.FirstOrDefault(u => u.FirstName.Equals(firstname));

                var searchKeyAdd = db.Nurse.Select(u => u.Key_Address);
                var materializeAddKey = searchKeyAdd.ToList();
                var KeyAdd = materializeAddKey[0];
                var AddModel = db.Address.FirstOrDefault(u => u.Id.Equals(KeyAdd));

                var searchKeyCon = db.Nurse.Select(u => u.Key_Contact);
                var materializeConKey = searchKeyCon.ToList();
                var KeyCon = materializeConKey[0];
                var ConModel = db.Contact.FirstOrDefault(u => u.Id.Equals(KeyCon));

                var searchUserKey = db.Nurse.Select(u => u.Key_Users);
                var materializeUserKey = searchUserKey.ToList();
                var KeyUser = materializeUserKey[0];
                var UsersModel = db.Users.FirstOrDefault(u => u.Id.Equals(KeyUser));

                var password = CustomDecrypt.Decrypt(UsersModel.Password);

                UsersModel.Password = password;

                var viewmodel = new NurseModel
                {
                    Contact = ConModel,
                    Address = AddModel,
                    Nurse = NurseModel,
                    Users = UsersModel
                };

                return View(viewmodel);
            }
        }
        public IEnumerable <NurseModel> UpdateNurse(NurseModel updatedNurse)
        {
            IEnumerable <NurseModel> result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Utils.Url());

                    client.DefaultRequestHeaders.Clear();

                    var jsonData = JsonConvert.SerializeObject(updatedNurse);

                    var buffer = System.Text.Encoding.UTF8.GetBytes(jsonData);

                    var byteContent = new ByteArrayContent(buffer);

                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                    HttpResponseMessage Res = client.PostAsync(Utils.Url() + "Nurse/UpdateNurse", byteContent).Result;

                    if (Res.IsSuccessStatusCode && Res != null)
                    {
                        var res = (Res.Content.ReadAsAsync <IEnumerable <NurseModel> >().Result);

                        result = res;
                        Utils.Logging(Environment.StackTrace, null);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                Utils.Logging(ex, 2);
                return(result);
            }
        }
Exemplo n.º 9
0
        public ActionResult EditProfile()
        {
            using (var db = new MainDbContext())
            {
                string firstname  = User.Identity.Name;
                var    NurseModel = db.Nurse.FirstOrDefault(u => u.FirstName.Equals(firstname));

                var searchKeyAdd      = db.Nurse.Select(u => u.Key_Address);
                var materializeAddKey = searchKeyAdd.ToList();
                var KeyAdd            = materializeAddKey[0];
                var AddModel          = db.Address.FirstOrDefault(u => u.Id.Equals(KeyAdd));

                var searchKeyCon      = db.Nurse.Select(u => u.Key_Contact);
                var materializeConKey = searchKeyCon.ToList();
                var KeyCon            = materializeConKey[0];
                var ConModel          = db.Contact.FirstOrDefault(u => u.Id.Equals(KeyCon));

                var searchUserKey      = db.Nurse.Select(u => u.Key_Users);
                var materializeUserKey = searchUserKey.ToList();
                var KeyUser            = materializeUserKey[0];
                var UsersModel         = db.Users.FirstOrDefault(u => u.Id.Equals(KeyUser));

                var password = CustomDecrypt.Decrypt(UsersModel.Password);

                UsersModel.Password = password;

                var viewmodel = new NurseModel
                {
                    Contact = ConModel,
                    Address = AddModel,
                    Nurse   = NurseModel,
                    Users   = UsersModel
                };

                return(View(viewmodel));
            }
        }
Exemplo n.º 10
0
        public ActionResult CreateNurse(NurseModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Users.Username);
                    if (queryUser == null)
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);

                        var nurse   = db.Nurse.Create();
                        var address = db.Address.Create();
                        var contact = db.Contact.Create();
                        var user    = db.Users.Create();
                        var role    = db.Role.Create();
                        nurse.FirstName     = model.Nurse.FirstName;
                        nurse.MiddleName    = model.Nurse.MiddleName;
                        nurse.LastName      = model.Nurse.LastName;
                        nurse.Email         = model.Nurse.Email;
                        nurse.EmployeeId    = model.Nurse.EmployeeId;
                        nurse.LicenseNo     = model.Nurse.LicenseNo;
                        nurse.HospName      = model.Nurse.HospName;
                        nurse.DateBirth     = model.Nurse.DateBirth;
                        nurse.Sex           = model.Nurse.Sex;
                        address.AddressType = model.Address.AddressType;
                        address.City        = model.Address.City;
                        address.Province    = model.Address.Province;
                        address.Zipcode     = model.Address.Zipcode;
                        user.Username       = model.Users.Username;
                        user.Password       = encryptedPassword;
                        user.Password       = encryptedPassword;
                        role.RoleType       = "nurse";
                        nurse.SecQuestion   = model.Nurse.SecQuestion;
                        nurse.SecAnswer     = model.Nurse.SecAnswer;
                        contact.MobileNo    = model.Contact.MobileNo;
                        contact.PhoneNo     = model.Contact.PhoneNo;

                        db.Address.Add(address);
                        db.Contact.Add(contact);
                        db.Role.Add(role);
                        db.SaveChanges();

                        user.Key_Role = role.Id;
                        db.Users.Add(user);
                        db.SaveChanges();

                        nurse.Key_Users   = user.Id;
                        nurse.Key_Address = address.Id;
                        nurse.Key_Contact = contact.Id;
                        db.Nurse.Add(nurse);
                        db.SaveChanges();

                        return(RedirectToAction("CreateNurse", "Admin"));
                    }
                    else
                    {
                        return(RedirectToAction("CreateNurse", "Admin"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields is incorrect");
            }
            return(View());
        }
Exemplo n.º 11
0
        public ActionResult EditProfile(NurseModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    string firstname = User.Identity.Name;

                    //Get Doctor
                    var NurseModel = db.Nurse.FirstOrDefault(u => u.FirstName.Equals(firstname));
                    NurseModel.HospName    = model.Nurse.HospName;
                    NurseModel.EmployeeId  = model.Nurse.EmployeeId;
                    NurseModel.LicenseNo   = model.Nurse.LicenseNo;
                    NurseModel.FirstName   = model.Nurse.FirstName;
                    NurseModel.MiddleName  = model.Nurse.MiddleName;
                    NurseModel.LastName    = model.Nurse.LastName;
                    NurseModel.Email       = model.Nurse.Email;
                    NurseModel.DateBirth   = model.Nurse.DateBirth;
                    NurseModel.Sex         = model.Nurse.Sex;
                    NurseModel.SecQuestion = model.Nurse.SecQuestion;
                    NurseModel.SecAnswer   = model.Nurse.SecAnswer;

                    db.Entry(NurseModel).State = EntityState.Modified;

                    // Get the Address
                    var searchKeyAdd      = db.Nurse.Select(u => u.Key_Address);
                    var materializeAddKey = searchKeyAdd.ToList();
                    var KeyAdd            = materializeAddKey[0];
                    var AddModel          = db.Address.FirstOrDefault(u => u.Id.Equals(KeyAdd));

                    AddModel.City        = model.Address.City;
                    AddModel.Province    = model.Address.Province;
                    AddModel.Zipcode     = model.Address.Zipcode;
                    AddModel.AddressType = model.Address.AddressType;

                    db.Entry(AddModel).State = EntityState.Modified;

                    // Get the Contact
                    var searchKeyCon      = db.Nurse.Select(u => u.Key_Contact);
                    var materializeConKey = searchKeyCon.ToList();
                    var KeyCon            = materializeConKey[0];
                    var ConModel          = db.Contact.FirstOrDefault(u => u.Id.Equals(KeyCon));

                    ConModel.MobileNo = model.Contact.MobileNo;
                    ConModel.PhoneNo  = model.Contact.PhoneNo;

                    db.Entry(ConModel).State = EntityState.Modified;

                    // Get the Users
                    var searchUserKey      = db.Nurse.Select(u => u.Key_Users);
                    var materializeUserKey = searchUserKey.ToList();
                    var KeyUser            = materializeUserKey[0];
                    var UsersModel         = db.Users.FirstOrDefault(u => u.Id.Equals(KeyUser));

                    var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);
                    UsersModel.Username = model.Users.Username;
                    UsersModel.Password = encryptedPassword;

                    db.Entry(UsersModel).State = EntityState.Modified;


                    db.SaveChanges();

                    var identity = new ClaimsIdentity(new[] {
                        new Claim(ClaimTypes.Name, NurseModel.FirstName),
                        new Claim(ClaimTypes.Role, "FDR")
                    }, "ApplicationCookie");

                    var ctx = Request.GetOwinContext();

                    var authManager = ctx.Authentication;

                    authManager.SignIn(identity);


                    return(RedirectToAction("Index", "Nurse"));
                }
            }

            return(View(model));
        }
Exemplo n.º 12
0
        public ActionResult EditProfile(NurseModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    string firstname = User.Identity.Name;

                    //Get Doctor
                    var NurseModel = db.Nurse.FirstOrDefault(u => u.FirstName.Equals(firstname));
                    NurseModel.HospName = model.Nurse.HospName;
                    NurseModel.EmployeeId = model.Nurse.EmployeeId;
                    NurseModel.LicenseNo = model.Nurse.LicenseNo;
                    NurseModel.FirstName = model.Nurse.FirstName;
                    NurseModel.MiddleName = model.Nurse.MiddleName;
                    NurseModel.LastName = model.Nurse.LastName;
                    NurseModel.Email = model.Nurse.Email;
                    NurseModel.DateBirth = model.Nurse.DateBirth;
                    NurseModel.Sex = model.Nurse.Sex;
                    NurseModel.SecQuestion = model.Nurse.SecQuestion;
                    NurseModel.SecAnswer = model.Nurse.SecAnswer;

                    db.Entry(NurseModel).State = EntityState.Modified;

                    // Get the Address
                    var searchKeyAdd = db.Nurse.Select(u => u.Key_Address);
                    var materializeAddKey = searchKeyAdd.ToList();
                    var KeyAdd = materializeAddKey[0];
                    var AddModel = db.Address.FirstOrDefault(u => u.Id.Equals(KeyAdd));

                    AddModel.City = model.Address.City;
                    AddModel.Province = model.Address.Province;
                    AddModel.Zipcode = model.Address.Zipcode;
                    AddModel.AddressType = model.Address.AddressType;

                    db.Entry(AddModel).State = EntityState.Modified;

                    // Get the Contact
                    var searchKeyCon = db.Nurse.Select(u => u.Key_Contact);
                    var materializeConKey = searchKeyCon.ToList();
                    var KeyCon = materializeConKey[0];
                    var ConModel = db.Contact.FirstOrDefault(u => u.Id.Equals(KeyCon));

                    ConModel.MobileNo = model.Contact.MobileNo;
                    ConModel.PhoneNo = model.Contact.PhoneNo;

                    db.Entry(ConModel).State = EntityState.Modified;

                    // Get the Users
                    var searchUserKey = db.Nurse.Select(u => u.Key_Users);
                    var materializeUserKey = searchUserKey.ToList();
                    var KeyUser = materializeUserKey[0];
                    var UsersModel = db.Users.FirstOrDefault(u => u.Id.Equals(KeyUser));

                    var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);
                    UsersModel.Username = model.Users.Username;
                    UsersModel.Password = encryptedPassword;

                    db.Entry(UsersModel).State = EntityState.Modified;

                    db.SaveChanges();

                    var identity = new ClaimsIdentity(new[] {
                           new Claim(ClaimTypes.Name, NurseModel.FirstName),
                           new Claim(ClaimTypes.Role, "FDR")
                           }, "ApplicationCookie");

                    var ctx = Request.GetOwinContext();

                    var authManager = ctx.Authentication;

                    authManager.SignIn(identity);

                    return RedirectToAction("Index", "Nurse");
                }

            }

            return View(model);
        }
Exemplo n.º 13
0
        public ActionResult CreateNurse(NurseModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Users.Username);
                    if (queryUser == null)
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);

                        var nurse = db.Nurse.Create();
                        var address = db.Address.Create();
                        var contact = db.Contact.Create();
                        var user = db.Users.Create();
                        var role = db.Role.Create();
                        nurse.FirstName = model.Nurse.FirstName;
                        nurse.MiddleName = model.Nurse.MiddleName;
                        nurse.LastName = model.Nurse.LastName;
                        nurse.Email = model.Nurse.Email;
                        nurse.EmployeeId = model.Nurse.EmployeeId;
                        nurse.LicenseNo = model.Nurse.LicenseNo;
                        nurse.HospName = model.Nurse.HospName;
                        nurse.DateBirth = model.Nurse.DateBirth;
                        nurse.Sex = model.Nurse.Sex;
                        address.AddressType = model.Address.AddressType;
                        address.City = model.Address.City;
                        address.Province = model.Address.Province;
                        address.Zipcode = model.Address.Zipcode;
                        user.Username = model.Users.Username;
                        user.Password = encryptedPassword;
                        user.Password = encryptedPassword;
                        role.RoleType = "nurse";
                        nurse.SecQuestion = model.Nurse.SecQuestion;
                        nurse.SecAnswer = model.Nurse.SecAnswer;
                        contact.MobileNo = model.Contact.MobileNo;
                        contact.PhoneNo = model.Contact.PhoneNo;

                        db.Address.Add(address);
                        db.Contact.Add(contact);
                        db.Role.Add(role);
                        db.SaveChanges();

                        user.Key_Role = role.Id;
                        db.Users.Add(user);
                        db.SaveChanges();

                        nurse.Key_Users = user.Id;
                        nurse.Key_Address = address.Id;
                        nurse.Key_Contact = contact.Id;
                        db.Nurse.Add(nurse);
                        db.SaveChanges();

                        return RedirectToAction("CreateNurse", "Admin");
                    }
                    else
                    {
                        return RedirectToAction("CreateNurse", "Admin");
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields is incorrect");
            }
            return View();
        }
 public static NurseMaster ToEntity(this NurseModel model)
 {
     return(model.MapTo <NurseModel, NurseMaster>());
 }
        public IActionResult CreateNurse(NurseModel model)
        {//10/10/2019 aakansha
            ViewBag.FormName = "Nurse";
            if (!(bool)SharedData.isNurseMenuAccessible)
            {
                return(AccessDeniedView());
            }
            Customer customer = null;

            CustomerPassword password = null;

            if (model.Id == 0)
            {
                if (!string.IsNullOrWhiteSpace(model.BillingAddress.Email))
                {
                    model.Phone = model.BillingAddress.PhoneNumber;
                    customer    = _customerServices.GetCustomerByEmail(model.BillingAddress.Email);
                    if (customer != null)
                    {
                        if (model.Id == 0)
                        {
                            AddNotification(NotificationMessage.TitleError, NotificationMessage.Emailisalreadyregistered, NotificationMessage.TypeError);
                            return(RedirectToAction("Create"));
                        }
                    }
                }
                //Address Data
                var Baddress = new Address();
                Baddress.FirstName     = _encryptionService.EncryptText(model.BillingAddress.FirstName);
                Baddress.LastName      = _encryptionService.EncryptText(model.BillingAddress.LastName);
                Baddress.PhoneNumber   = _encryptionService.EncryptText(model.BillingAddress.PhoneNumber);
                Baddress.StateProvince = _encryptionService.EncryptText(model.BillingAddress.StateProvince);
                Baddress.ZipPostalCode = _encryptionService.EncryptText(model.BillingAddress.ZipPostalCode);
                Baddress.Email         = _encryptionService.EncryptText(model.BillingAddress.Email);
                Baddress.City          = _encryptionService.EncryptText(model.BillingAddress.City);
                Baddress.Address1      = _encryptionService.EncryptText(model.BillingAddress.Address1);
                Baddress.Address2      = _encryptionService.EncryptText(model.BillingAddress.Address2);

                Baddress.CreatedOnUtc = DateTime.UtcNow;
                //Inser Nurse Data In User Table
                customer = new Customer();


                customer.CustomerGuid = Guid.NewGuid();
                customer.Email        = _encryptionService.EncryptText(model.BillingAddress.Email);
                customer.Username     = _encryptionService.EncryptText(model.BillingAddress.Email);
                var nurseRoleData = _customerServices.GetAllCustomerRoles().Where(a => a.Name == "Nurse").FirstOrDefault();
                customer.CustomerRoleId      = nurseRoleData.Id;
                customer.Active              = true;
                customer.CreatedOnUtc        = DateTime.UtcNow;
                customer.LastActivityDateUtc = DateTime.UtcNow;


                _customerServices.InsertCustomer(customer);
                //customer.CustomerRoles.Add();
                customer.Addresses.Add(Baddress);
                customer.BillingAddress = Baddress;
                _customerServices.UpdateCustomer(customer);
                // password
                if (!string.IsNullOrWhiteSpace(model.CustomerPassword.Password))
                {
                    password = new CustomerPassword
                    {
                        CustomerId   = customer.Id,
                        Password     = model.CustomerPassword.Password,
                        CreatedOnUtc = DateTime.UtcNow,
                        //default passwordFormat
                        PasswordFormat = PasswordFormat.Clear
                    };
                    _customerpasswordservice.InsertCustomerPassword(password);
                }
                //General Data
                var data = new NurseMaster();

                data.Email     = _encryptionService.EncryptText(model.BillingAddress.Email);
                data.UserId    = customer.Id;
                data.FirstName = _encryptionService.EncryptText(model.BillingAddress.FirstName);
                data.LastName  = _encryptionService.EncryptText(model.BillingAddress.LastName);
                data.CreatedOn = DateTime.UtcNow;
                data.Deleted   = false;

                _nurseServices.InsertNurse(data);
                return(Json(data.Id));
            }
            else
            {
                var data = _nurseServices.GetNurseById(model.Id);
                customer = _customerServices.GetCustomerById((int)data.UserId);
                //Address Data
                var Baddress = _addressservice.GetAddressById(customer.BillingAddress.Id);
                Baddress.FirstName     = _encryptionService.EncryptText(model.BillingAddress.FirstName);
                Baddress.LastName      = _encryptionService.EncryptText(model.BillingAddress.LastName);
                Baddress.PhoneNumber   = _encryptionService.EncryptText(model.BillingAddress.PhoneNumber);
                Baddress.StateProvince = _encryptionService.EncryptText(model.BillingAddress.StateProvince);
                Baddress.ZipPostalCode = _encryptionService.EncryptText(model.BillingAddress.ZipPostalCode);
                Baddress.Email         = _encryptionService.EncryptText(model.BillingAddress.Email);
                Baddress.City          = _encryptionService.EncryptText(model.BillingAddress.City);
                Baddress.Address1      = _encryptionService.EncryptText(model.BillingAddress.Address1);
                Baddress.Address2      = _encryptionService.EncryptText(model.BillingAddress.Address2);
                //Update address
                _addressservice.UpdateAddress(Baddress);
                //Inser Nurse Data In User Table

                customer.CustomerGuid = Guid.NewGuid();
                customer.Email        = _encryptionService.EncryptText(model.BillingAddress.Email);
                customer.Username     = _encryptionService.EncryptText(model.BillingAddress.Email);
                var nurseRoleData = _customerServices.GetAllCustomerRoles().Where(a => a.Name == "Nurse").FirstOrDefault();
                customer.CustomerRoleId      = nurseRoleData.Id;
                customer.Active              = true;
                customer.CreatedOnUtc        = DateTime.UtcNow;
                customer.LastActivityDateUtc = DateTime.UtcNow;

                _customerServices.UpdateCustomer(customer);

                // password
                if (!string.IsNullOrWhiteSpace(model.CustomerPassword.Password))
                {
                    password          = _customerpasswordservice.GetPasswordByCustomerId((int)data.UserId);
                    password.Password = model.CustomerPassword.Password;
                    _customerpasswordservice.UpdatePassword(password);
                }
                //Genereal Data
                data.Email       = _encryptionService.EncryptText(model.BillingAddress.Email);
                data.FirstName   = _encryptionService.EncryptText(model.BillingAddress.FirstName);
                data.LastName    = _encryptionService.EncryptText(model.BillingAddress.LastName);
                data.Deleted     = false;
                data.LastUpdated = DateTime.UtcNow;
                _nurseServices.UpdateNurse(data);
                return(Json(data.Id));
            }
        }
Exemplo n.º 16
0
        public override void Handle()
        {
            Console.Clear();
            Console.WriteLine("CREATE NEW USER");

            User user = new User();

            Console.Write("First name: ");
            user.Firstname = Console.ReadLine();
            Console.Write("Last name: ");
            user.Lastname = Console.ReadLine();
            Console.Write("PESEL: ");
            user.Pesel = Console.ReadLine();
            Console.Write("Username: "******"Password: "******"USER TYPE");
            Console.WriteLine("1. Admin");
            Console.WriteLine("2. Nurse");
            Console.WriteLine("3. Doctor");
            int  input      = 0;
            User userFromDb = null;

            while (!int.TryParse(Console.ReadLine(), out input))
            {
                Console.WriteLine("Wrong Input!");
            }
            switch (input)
            {
            case 1:
                user.TypableType = "admin";
                userFromDb       = new UserModel().CreateUser(user);
                Admin adminFromDb = new AdminModel().CreateAdmin(new Admin {
                    Id = userFromDb.Id
                });
                userFromDb.TypableId = adminFromDb.Id;
                new UserModel().UpdateUser(userFromDb);
                break;

            case 2:
                user.TypableType = "Nurse";
                userFromDb       = new UserModel().CreateUser(user);
                Nurse nurseFromDb = new NurseModel().CreateNurse(new Nurse {
                    Id = userFromDb.Id
                });
                userFromDb.TypableId = nurseFromDb.Id;
                new UserModel().UpdateUser(userFromDb);
                break;

            case 3:
                user.TypableType = "doctor";
                Doctor doctor = new Doctor();
                Console.Write("Speciality: ");
                doctor.Speciality = Console.ReadLine();
                Console.Write("PWZ: ");
                doctor.Pwz    = Console.ReadLine();
                userFromDb    = new UserModel().CreateUser(user);
                doctor.UserId = userFromDb.Id;
                Doctor doctorFromDb = new DoctorModel().CreateDoctor(doctor);
                userFromDb.TypableId = doctorFromDb.Id;
                new UserModel().UpdateUser(userFromDb);
                break;

            default:
                Console.WriteLine("Wrong Input!");
                break;
            }
            Console.WriteLine("User succesfully added!");
        }
        public ActionResult SaveNurse(NurseModel nurse)
        {
            ViewBag.message = nurseManager.Save(nurse);

            return(View());
        }
 public static NurseMaster ToEntity(this NurseModel model, NurseMaster destination)
 {
     return(model.MapTo(destination));
 }