Exemple #1
0
 public List <MedicineDetail> GetContacts(int afterDate)
 {
     using (PharmacySystemEntities dc = new PharmacySystemEntities())
     {
         return(dc.MedicineDetails.Where(a => a.M_ID > 9).ToList());
     }
 }
Exemple #2
0
 public bool IsEmailExist(string email)
 {
     using (PharmacySystemEntities dc = new PharmacySystemEntities())
     {
         var v = dc.CustomerLogins.Where(a => a.Email == email).FirstOrDefault();
         return(v != null);
     }
 }
Exemple #3
0
 public JsonResult GetEvents()
 {
     //Here MyDatabaseEntities is our entity datacontext (see Step 4)
     using (PharmacySystemEntities dc = new PharmacySystemEntities())
     {
         var v = dc.Demo_Events.OrderBy(a => a.StartAt).ToList();
         return(new JsonResult {
             Data = v, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Exemple #4
0
        public ActionResult Login(LoginCustomer login, string ReturnUrl = "")
        {
            string message = "";

            using (PharmacySystemEntities dc = new PharmacySystemEntities())
            {
                var v = dc.CustomerLogins.Where(a => a.Email == login.Email).FirstOrDefault();
                if (v != null)
                {
                    if (v.IsEmailVerified == false)
                    {
                        ViewBag.n       = 1;
                        message         = "Incorrect EmailID or Password";
                        ViewBag.Message = message;
                        return(View("Login"));
                    }
                    if (string.Compare(Crypto.Hash(login.Password), v.Password) == 0)
                    {
                        int    timeout   = login.RememberMe ? 525600 : 20; // 525600 min = 1 year
                        var    ticket    = new FormsAuthenticationTicket(login.Email, login.RememberMe, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;
                        Response.Cookies.Add(cookie);


                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            Session["Customer"] = v.Email;
                            return(RedirectToAction("Index", "CustomerHome"));
                        }
                    }
                    else
                    {
                        ViewBag.n = 1;
                        message   = "Incorrect EmailID or Password";
                    }
                }
                else
                {
                    ViewBag.n = 1;
                    message   = "Incorrect EmailID or Password";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Exemple #5
0
        public JsonResult DeleteEvent(int eventID)
        {
            bool status = false;

            using (PharmacySystemEntities dc = new PharmacySystemEntities())
            {
                var v = dc.Demo_Events.Where(a => a.EventID.Equals(eventID)).FirstOrDefault();
                if (v != null)
                {
                    dc.Demo_Events.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult CharterColumn()
        {
            var _context = new PharmacySystemEntities();

            ArrayList xValue = new ArrayList();
            ArrayList yValue = new ArrayList();

            var results = (from c in _context.MedicineDetails select c);

            results.ToList().ForEach(rs => xValue.Add(rs.MedicineName));
            results.ToList().ForEach(rs => yValue.Add(rs.Quantity));

            new Chart(width: 600, height: 400, theme: ChartTheme.Yellow)
            .AddTitle("Medicines Details [Column Chart]")
            .AddSeries("Default", chartType: "column", xValue: xValue, yValues: yValue)
            .Write("bmp");

            return(null);
        }
Exemple #7
0
        public JsonResult SaveEvent(Demo_Events evt)
        {
            bool status = false;

            using (PharmacySystemEntities dc = new PharmacySystemEntities())
            {
                if (evt.EndAt != null && evt.StartAt.TimeOfDay == new TimeSpan(0, 0, 0) &&
                    evt.EndAt.Value.TimeOfDay == new TimeSpan(0, 0, 0))
                {
                    evt.IsFullDay = true;
                }
                else
                {
                    evt.IsFullDay = false;
                }
                if (evt.EventID > 0)
                {
                    var v = dc.Demo_Events.Where(a => a.EventID.Equals(evt.EventID)).FirstOrDefault();
                    if (v != null)
                    {
                        v.Title       = evt.Title;
                        v.Description = evt.Description;
                        v.StartAt     = evt.StartAt;
                        v.EndAt       = evt.EndAt;
                        v.IsFullDay   = evt.IsFullDay;
                    }
                }
                else
                {
                    dc.Demo_Events.Add(evt);
                }
                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Exemple #8
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (PharmacySystemEntities dc = new PharmacySystemEntities())
            {
                dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid
                                                                // Confirm password does not match issue on save changes
                var v = dc.CustomerLogins.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }
Exemple #9
0
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] CustomerLogin customer)
        {
            bool   Status  = false;
            string message = "";

            //
            // Model Validation
            if (customer.Email == null)
            {
                ViewBag.Emty = "Email is required";
                return(View(customer));
            }

            #region     //Email is already Exist
            var isExist = IsEmailExist(customer.Email);
            if (isExist)
            {
                ViewBag.Emty = "Email already exist";
                //ModelState.AddModelError("EmailExist", "Email already exist");
                return(View(customer));
            }
            #endregion

            #region Generate Activation Code
            customer.ActivationCode = Guid.NewGuid();
            #endregion

            #region  Password Hashing
            if (customer.Password == null)
            {
                ViewBag.Password = "******";
                return(View());
            }

            string pattern = @"^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{6,20}$";
            Match  result  = Regex.Match(customer.Password, pattern);

            if (!result.Success)
            {
                ViewBag.Password = "******";
                return(View());
            }


            string pattern1 = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
            Match  result1  = Regex.Match(customer.Email, pattern1);

            if (!result1.Success)
            {
                ViewBag.Emty = "Invalid Email Address";
                return(View());
            }


            customer.Password = Crypto.Hash(customer.Password);
            //customer.ConfirmPassword = Crypto.Hash(customer.ConfirmPassword); //
            #endregion
            customer.IsEmailVerified = false;

            #region Save to Database

            //Send Email to User
            SendVerificationLinkEmail(customer.Email, customer.ActivationCode.ToString());
            message = "Registration successfully done. Account activation link " +
                      " has been sent to your email id:" + customer.Email;
            Status = true;
            if (mailSent == false)
            {
                ViewBag.noSentEmail    = "True";
                ViewBag.EmailNetConMsg = "There is no Internet connection";
                return(View());
            }

            using (PharmacySystemEntities dc = new PharmacySystemEntities())
            {
                if (customer.Email.ToLower().Contains('@'))
                {
                    try
                    {
                        dc.CustomerLogins.Add(customer);
                        dc.SaveChanges();
                    }
                    catch (DbEntityValidationException e)
                    {
                        foreach (var eve in e.EntityValidationErrors)
                        {
                            Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                              eve.Entry.Entity.GetType().Name, eve.Entry.State);
                            foreach (var ve in eve.ValidationErrors)
                            {
                                Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                  ve.PropertyName, ve.ErrorMessage);
                            }
                        }
                        return(View());
                    }
                }
                else
                {
                    ViewBag.EmailValid = "Invalid Email Address";
                    return(View());
                }
            }
            #endregion


            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(customer));
        }