Esempio n. 1
0
 public List <Role> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.Roles.ToList());
     }
 }
        public bool Create(User model)
        {
            if (model != null)
            {
                using (AuthenticationDB db = new AuthenticationDB())
                {
                    //db.Users.Add(model);
                    //return (db.SaveChanges() > 0) ? true : false;


                    var rows = db.Database.ExecuteSqlCommand(ResourceSQL.SP_InsertUserAddRoleDefault,
                                                             new SqlParameter("@USR_IDE_AREA", model.USR_IDE_AREA),
                                                             new SqlParameter("@USR_DES_POSITION", model.USR_DES_POSITION),
                                                             new SqlParameter("@USR_DES_NAME", model.USR_DES_NAME),
                                                             new SqlParameter("@USR_DES_FIRST_NAME", model.USR_DES_FIRST_NAME),
                                                             new SqlParameter("@USR_DES_LAST_NAME", model.USR_DES_LAST_NAME),
                                                             new SqlParameter("@USR_DES_PASSWORD", model.USR_DES_PASSWORD),
                                                             new SqlParameter("@USR_DES_PHONE", model.USR_DES_PHONE),
                                                             new SqlParameter("@USR_DES_EMAIL", model.USR_DES_EMAIL),
                                                             new SqlParameter("@USR_FH_CREATED", model.USR_FH_CREATED)
                                                             );


                    return((rows > 0) ? true : false);
                }
            }
            return(false);
        }
Esempio n. 3
0
 public List <AccountingAccount> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.AccountingAccounts.ToList());
     }
 }
Esempio n. 4
0
        public ActionResult Orders()
        {
            using (var db = new AuthenticationDB())
            {
                string pharmacy = db.Pharms.FirstOrDefault(u =>
                                                           u.RefUser.UserId == ((OrdPrincipal)HttpContext.User).UserID).Pharmacy;

                var VM = db.Docs.Where(d =>
                                       d.RefUser.UserId == db.Pharms
                                       .FirstOrDefault(p => p.RefUser.UserId == ((OrdPrincipal)User).UserID).Doc.UserId)
                         .Select(d => new DocPrice
                {
                    Id        = d.DocID,
                    FirstName = d.RefUser.FirstName,
                    LastName  = d.RefUser.LastName,
                    Price     = d.Patients
                                .SelectMany(p => p.Medicines)
                                .Where(m => m.PharmacyName == pharmacy)
                                .Sum(x => x.Price) == null
                            ? 0
                            : d.Patients
                                .SelectMany(p => p.Medicines)
                                .Where(m => m.PharmacyName == pharmacy)
                                .Sum(x => x.Price)
                }).ToList();
                return(View(VM));
            }
        }
 public List <Budget> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.Budgets.ToList());
     }
 }
 public List <StatusAprov> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.StatusAprovs.ToList());
     }
 }
Esempio n. 7
0
        void SeedUsers(AuthenticationDB context)
        {
            if (!isInitDb)
            {
                return;
            }

            var    pwd    = new PasswordHasher();
            string hashed = pwd.HashPassword("admin@123");
            User   admin  = new User()
            {
                UserName             = "******",
                Email                = "*****@*****.**",
                EmailConfirmed       = true,
                PhoneNumber          = "+84936124031",
                PhoneNumberConfirmed = true,
                SecurityStamp        = Guid.NewGuid().ToString("D"),
                PasswordHash         = hashed
            };

            if (!context.Users.Any(u => u.UserName == admin.UserName))
            {
                var userStore = new UserStore <User>(context);
                var result    = userStore.CreateAsync(admin);
                foreach (string role in roles)
                {
                    userStore.AddToRoleAsync(admin, role);
                }
            }
            context.SaveChanges();
        }
Esempio n. 8
0
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword))
            {
                return(false);
            }

            using (AuthenticationDB dbContext = new AuthenticationDB())
            {
                var user = (from us in dbContext.Users
                            where string.Compare(username, us.Username, StringComparison.OrdinalIgnoreCase) == 0 &&
                            string.Compare(oldPassword, us.Password, StringComparison.OrdinalIgnoreCase) == 0 &&
                            us.IsActive == true
                            select us).FirstOrDefault();

                if (user == null)
                {
                    return(false);
                }

                user.Password = newPassword;
                dbContext.SaveChanges();
                return(true);
            }
        }
 public List <User> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.Users.ToList());
     }
 }
Esempio n. 10
0
 public List <Request> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.Requests.ToList());
     }
 }
Esempio n. 11
0
 public List <Invoice> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.Invoices.ToList());
     }
 }
Esempio n. 12
0
        public ActionResult RegisterUserEdit(User user, int id)
        {
            var model = AuthenticationDB.GetUserByEmail(user.Email);

            if (model != null)
            {
                if (model.UserId != user.UserId)
                {
                    ModelState.AddModelError("Warning Email", "Sorry: Email already Exists");
                    return(View(user));
                }
            }
            else
            {
                model = AuthenticationDB.GetUserById(user.UserId);
            }
            model.FullName             = user.FullName;
            model.Email                = user.Email;
            model.IsActive             = user.IsActive;
            model.Phone                = user.Phone;
            model.CommunicationAddress = user.CommunicationAddress;
            AuthenticationDB.Save(model);

            return(RedirectToAction("RegisterUser"));
        }
Esempio n. 13
0
        public ActionResult RegisterUserEdit(int id)
        {
            var model = AuthenticationDB.GetUserById(id);

            // View Model Conversation here....
            return(View(model));
        }
Esempio n. 14
0
 public List <Area> GetAll()
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         return(db.Areas.ToList());
     }
 }
Esempio n. 15
0
 public void EditCoWorker(int id, string pas)
 {
     using (var db = new AuthenticationDB())
     {
         db.Usrs.FirstOrDefault(x => x.UserId == id).UserPassword = pas;
         db.SaveChanges();
     }
 }
Esempio n. 16
0
        public ActionResult UserProfile()
        {
            var name  = User.Identity.Name;
            var model = AuthenticationDB.GetUserByEmail(name);

            // View Model Conversation here....
            return(View(model));
        }
Esempio n. 17
0
        public ActionResult ChangeStatus(int id)
        {
            var model = AuthenticationDB.GetUserById(id);

            model.IsActive = !model.IsActive;
            AuthenticationDB.Save(model);
            return(RedirectToAction("RegisterUser"));
        }
 public User GetOne(string id)
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         User User = db.Users.Find(id);
         return(User);
     }
 }
 public void Create(User model)
 {
     using (AuthenticationDB db = new AuthenticationDB())
     {
         db.Users.Add(model);
         db.SaveChanges();
     }
 }
Esempio n. 20
0
        public ActionResult Medicines()
        {
            using (var db = new AuthenticationDB())
            {
                var pharmacy = db.Pharms.FirstOrDefault(u =>
                                                        u.RefUser.UserId == ((OrdPrincipal)HttpContext.User).UserID).Pharmacy;

                return(View(db.Medicines.Where(m => m.PharmacyName == pharmacy).ToList()));
            }
        }
Esempio n. 21
0
 public PartialViewResult GetPatientData(int id)
 {
     using (var db = new AuthenticationDB())
     {
         Patient patient = db.Patients
                           .FirstOrDefault(x =>
                                           x.PatientID == id && x.Doctor.RefUser.UserId == ((OrdPrincipal)HttpContext.User).UserID);
         return(PartialView(patient));
     }
 }
Esempio n. 22
0
 public PartialViewResult RenderMedicines(string currentPharmacy, int currentPatient)
 {
     using (var db = new AuthenticationDB())
     {
         var VM = new DocMedicinesVM();
         VM.Medicines        = db.Medicines.Where(m => m.PharmacyName == currentPharmacy).ToList();
         VM.CurrentPatientId = currentPatient;
         return(PartialView(VM));
     }
 }
Esempio n. 23
0
 public void DeleteCoWorker(int id)
 {
     using (var db = new AuthenticationDB())
     {
         db.InWs.RemoveRange(db.InWs.Where(u => u.RefUser.UserId == id));
         db.Pharms.RemoveRange(db.Pharms.Where(u => u.RefUser.UserId == id));
         db.Usrs.RemoveRange(db.Usrs.Where(u => u.UserId == id));
         db.SaveChanges();
     }
 }
Esempio n. 24
0
        public ActionResult DeleteMedicine(int id)
        {
            using (var db = new AuthenticationDB())
            {
                db.Medicines.Remove(db.Medicines.FirstOrDefault(m => m.MedicineID == id));
                db.SaveChanges();
            }

            return(RedirectToAction("Medicines"));
        }
Esempio n. 25
0
 public PartialViewResult RenderMedicines(int id)
 {
     using (var db = new AuthenticationDB())
     {
         var VM = db.Patients.FirstOrDefault(p => p.PatientID == id).Medicines.ToList();
         ViewBag.Price = VM.Sum(x => x.Price);
         ViewBag.Id    = id;
         return(PartialView(VM));
     }
 }
Esempio n. 26
0
 public void DocInit()
 {
     doc           = new DoctorM();
     doc.Id        = ((OrdPrincipal)HttpContext.User).UserID;
     doc.FirstName = ((OrdPrincipal)HttpContext.User).FirstName;
     doc.LastName  = ((OrdPrincipal)HttpContext.User).LastName;
     using (AuthenticationDB context = new AuthenticationDB())
     {
         doc.Specialization = context.Docs.FirstOrDefault(d => d.RefUser.UserId == doc.Id)?.Specialization;
     }
 }
Esempio n. 27
0
 public void DeletePatient(int patient)
 {
     using (var db = new AuthenticationDB())
     {
         // ReSharper disable once AssignNullToNotNullAttribute
         db.Patients.Remove(db.Patients.FirstOrDefault(p => (p.PatientID == patient) &&
                                                       (p.Doctor.RefUser.UserId ==
                                                        ((OrdPrincipal)HttpContext.User).UserID)));
         db.SaveChanges();
     }
 }
Esempio n. 28
0
        public override string GetUserNameByEmail(string email)
        {
            var user = AuthenticationDB.GetUserByEmail(email);

            if (user == null)
            {
                return(null);
            }

            return(user != null ? user.Email : string.Empty);
        }
Esempio n. 29
0
        public override string GetPassword(string username, string answer)
        {
            using (AuthenticationDB dbContext = new AuthenticationDB())
            {
                var strPass = (from us in dbContext.Users
                               where string.Compare(username, us.Username, StringComparison.OrdinalIgnoreCase) == 0
                               select us).FirstOrDefault();

                return(strPass.Password);
            }
        }
Esempio n. 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public override bool ValidateUser(string username, string password)
        {
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            var user = AuthenticationDB.GetUserValidate(username, password);

            return((user != null) ? user.IsActive ? true : false : false);
        }