示例#1
0
        public ActionResult EditPharmacist(int PharmacistCode, int PharmacyCode, string FirstName, string LastName, string Email, string Phone, bool IsAdmin = false, bool IsActive = false)
        {
            Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", "");
            if (Phone.Length == 10)
            {
                Phone = "1" + Phone;
            }
            using (var service = new PharmacistService())
            {
                Pharmacist p = service.Get(PharmacistCode);
                if (p != null)
                {
                    p.FirstName = FirstName;
                    p.LastName  = LastName;
                    p.Phone     = Phone;
                    p.Email     = Email;
                    var temp1 = p.AllJobs.Where(x => x.Pharmacy.Code == PharmacyCode).FirstOrDefault();
                    using (var serviceJob = new JobService())
                    {
                        var j = serviceJob.GetWhere(JobService.CodeCol == temp1.Code).FirstOrDefault();
                        j.IsActive = IsActive;
                        j.IsAdmin  = IsAdmin;
                        serviceJob.Update(j);
                    }

                    service.Update(p);
                }
                return(RedirectToAction("SinglePharmacy", new RouteValueDictionary(
                                            new { controller = "SystemAdmin", action = "SinglePharmacy", Id = PharmacyCode })));
            }
        }
        public ActionResult EditPharmacist(int Code, int PharmacyCode, string FirstName, string LastName, string Email, string Phone, bool IsActive = false, bool IsAdmin = false)
        {
            Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", "");
            if (Phone.Length == 10)
            {
                Phone = "1" + Phone;
            }
            using (var service = new PharmacistService())
            {
                Pharmacist p = service.Get(Code);
                if (p != null)
                {
                    p.FirstName = FirstName;
                    p.LastName  = LastName;
                    p.Phone     = Phone;
                    p.Email     = Email;
                    service.Update(p);

                    using (var jobservice = new JobService())
                    {
                        //these get the value, not the checked value
                        var job = jobservice.GetWhere(JobService.PharmacistCodeCol == p.Code & JobService.PharmacyCodeCol == PharmacyCode).FirstOrDefault();
                        job.IsActive = IsActive;
                        job.IsAdmin  = IsAdmin;
                        jobservice.Update(job);
                    }
                }

                return(RedirectToAction("Pharmacy", new RouteValueDictionary(
                                            new { controller = "ManagePharmacist", action = "Pharmacy" })));
            }
        }
示例#3
0
 public JsonResult GetSinglePharmacist(int id, int PharmacyId)
 {
     using (var service = new PharmacistService())
     {
         var result = service.Get(id);
         return(Json(new PharmacistModel(result, PharmacyId)));
     }
 }
示例#4
0
 public static byte[] HashUserText(Pharmacist pharmacist, string text)
 {
     using (var service = new PharmacistService())
     {
         var salt = service.Get(pharmacist.Code).PasswordSalt;
         return(GenerateSaltedHash(Encoding.ASCII.GetBytes(text.ToLower()), salt));
     }
 }
示例#5
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            if (FormsAuthentication.CookiesSupported == true)
            {
                if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
                {
                    try
                    {
                        //get the username
                        FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value);
                        JavaScriptSerializer      serializer = new JavaScriptSerializer();

                        PPOKPrincipalSerializeModel serializeModel = serializer.Deserialize <PPOKPrincipalSerializeModel>(authTicket.UserData);

                        PPOKPrincipal newUser = new PPOKPrincipal(serializeModel.Email);
                        switch (serializeModel.Type)
                        {
                        case AccountTypes.Pharmacist:
                        case AccountTypes.Admin:
                            using (var service = new PharmacistService())
                            {
                                newUser = new PPOKPrincipal(service.Get(serializeModel.Code), serializeModel.Pharmacy.Code);
                            }
                            break;

                        case AccountTypes.Patient:
                            using (var service = new PatientService())
                            {
                                newUser = new PPOKPrincipal(service.Get(serializeModel.Code));
                            }
                            break;

                        case AccountTypes.System:
                            using (var service = new SystemAdminService())
                            {
                                newUser = new PPOKPrincipal(service.Get(serializeModel.Code));
                            }
                            break;
                        }

                        HttpContext.Current.User = newUser;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        //somehting went wrong
                    }
                }
            }
        }
示例#6
0
        public JsonResult Fill(int id)
        {
            Pharmacist pharm = new Pharmacist();

            using (var pharService = new PharmacistService())
            {
                pharm = pharService.Get(User.Code);
            }
            using (var service = new EventService())
            {
                var Er = service.Get(id);
                using (var fillservice = new FillHistoryService())
                {
                    FillHistory history = new FillHistory(Er.Refills.FirstOrDefault(), pharm, DateTime.Now);
                    fillservice.Create(history);
                }
                EventProcessingService.SendEvent(Er, User.Pharmacy.Code);
                return(Json(true));
            }
        }
 public ActionResult EditPharmacist(int Code, int PharmacyCode, string FirstName, string LastName, string Email, string Phone)
 {
     Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", "");
     if (Phone.Length == 10)
     {
         Phone = "1" + Phone;
     }
     using (var service = new PharmacistService())
     {
         Pharmacist p = service.Get(Code);
         if (p != null)
         {
             p.FirstName = FirstName;
             p.LastName  = LastName;
             p.Phone     = Phone;
             p.Email     = Email;
             service.Update(p);
         }
         return(RedirectToAction("SinglePharmacy", new RouteValueDictionary(
                                     new { controller = "SystemAdmin", action = "SinglePharmacy", Id = PharmacyCode })));
     }
 }