public ActionResult Create([Bind(Include = "allergyID,allergyName,active,cb,cd,mb,md")] Allergy allergy)
        {
            if (ModelState.IsValid)
            {
                db.Allergies.Add(allergy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(allergy));
        }
Beispiel #2
0
 public ActionResult Delete(int id)
 {
     if (Session["LogedUserID"] != null)
     {
         try
         {
             db.sp_DeleteAlerts(id, Session["LogedUserID"].ToString(), System.DateTime.Now);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         return(RedirectToAction("../Login/Index"));
     }
 }
 public ActionResult ApproveReview(FormCollection collection)
 {
     if (Session["LogedUserID"] != null)
     {
         try
         {
             var id = Request.Form["id"].ToString();
             db.sp_ApproveConsultation(Convert.ToInt64(id), Session["LogedUserID"].ToString(), System.DateTime.Now);
             db.SaveChanges();
             return(RedirectToAction("ReviewsApproval"));
         }
         catch (Exception ex)
         {
             return(RedirectToAction("ReviewsApproval"));
         }
     }
     else
     {
         return(RedirectToAction("AdminLogin", "Account"));
     }
 }
        public ActionResult Create(FormCollection collection)
        {
            if (Session["LogedUserID"] != null)
            {
                var systemitem   = "";
                var systemitemid = "";
                var systemid     = "";
                ViewBag.successMessage = "";
                ViewBag.errorMessage   = "";
                try
                {
                    var action = Request.Form["action"].ToString();
                    if (action == "create")
                    {
                        systemitem = Request.Form["systemitem"].ToString();
                        systemid   = Request.Form["sltSystem"].ToString();

                        var item = (
                            from p in db.SystemItemsses
                            where (p.systemItemName == systemitem && p.active == true)
                            select p
                            ).FirstOrDefault();
                        if (item != null)
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "System Item already exists";
                        }
                        if (item == null)
                        {
                            db.SP_AddSystemItem(systemitem, Convert.ToInt64(systemid), Session["LogedUserID"].ToString());
                            db.SaveChanges();
                            ViewBag.successMessage = "Record has been saved successfully";
                            ViewBag.errorMessage   = "";
                        }
                    }
                    if (action == "edit")
                    {
                        systemitemid = Request.Form["id"].ToString();
                        systemitem   = Request.Form["systemitem"].ToString();
                        systemid     = Request.Form["sltSystem"].ToString();
                        //var item = (
                        //               from p in db.SystemItemss
                        //               where (p.systemItemName == systemitem && p.active == true)
                        //               select p
                        //           ).FirstOrDefault();
                        //if (item != null)
                        //{
                        //    ViewBag.successMessage = "";
                        //    ViewBag.errorMessage = "System Item already exists";

                        //}
                        //if (item == null)
                        //{
                        db.sp_UpdateSystemItem(Convert.ToInt64(systemitemid), Convert.ToInt64(systemid), systemitem, Session["LogedUserID"].ToString(), System.DateTime.Now);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been saved successfully";
                        ViewBag.errorMessage   = "";
                        // }
                    }
                    if (action == "delete")
                    {
                        systemitemid = Request.Form["id"].ToString();
                        db.sp_DeleteSystemItem(Convert.ToInt64(systemitemid), Session["LogedUserID"].ToString(), System.DateTime.Now);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been deleted successfully";
                        ViewBag.errorMessage   = "";
                    }
                    var __existingitemList = db.SP_SelectSystemItems();
                    var systems            = db.PatientSystems
                                             .Where(a => a.active == true).ToList();
                    ViewBag.Systems  = systems;
                    ViewBag.systemid = systemid;
                    return(View(__existingitemList));
                }
                catch (Exception ex)
                {
                    ViewBag.errorMessage = "Error occurred while processing your request.";
                    var _existingitemList = db.SP_SelectSystemItems();
                    var systems           = db.PatientSystems.ToList();
                    ViewBag.Systems = systems;
                    return(View(_existingitemList));
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Account"));
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            if (Session["LogedUserID"] != null)
            {
                var languagename = "";
                var languageid   = "";
                ViewBag.successMessage = "";
                ViewBag.errorMessage   = "";
                try
                {
                    var action = Request.Form["action"].ToString();
                    if (action == "create")
                    {
                        languagename = Request.Form["languagename"].ToString();
                        var language = (
                            from p in db.Languages
                            where (p.languageName == languagename && p.active == true)
                            select p
                            ).FirstOrDefault();
                        if (language != null)
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Language already exists";
                        }
                        if (language == null)
                        {
                            db.SP_AddLanguage(languagename, Session["LogedUserID"].ToString());
                            db.SaveChanges();
                            ViewBag.successMessage = "Record has been saved successfully";
                            ViewBag.errorMessage   = "";
                        }
                    }
                    if (action == "edit")
                    {
                        languageid   = Request.Form["id"].ToString();
                        languagename = Request.Form["languagename"].ToString();
                        //var language = (
                        //               from p in db.Languages
                        //               where (p.languageName == languagename && p.active == true)
                        //               select p
                        //           ).FirstOrDefault();
                        //if (language != null)
                        //{
                        //    ViewBag.successMessage = "";
                        //    ViewBag.errorMessage = "Language already exists";

                        //}
                        //if (language == null)
                        //{
                        db.sp_UpdateLanguages(Convert.ToInt64(languageid), languagename, Session["LogedUserID"].ToString(), System.DateTime.Now);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been saved successfully";
                        ViewBag.errorMessage   = "";
                        //}
                    }
                    if (action == "delete")
                    {
                        languageid = Request.Form["id"].ToString();
                        db.sp_DeleteLanguage(Convert.ToInt64(languageid), Session["LogedUserID"].ToString(), System.DateTime.Now);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been deleted successfully";
                        ViewBag.errorMessage   = "";
                    }
                    var __existinglangList = db.SP_SelectLanguages();
                    return(View(__existinglangList));
                }
                catch (Exception ex)
                {
                    ViewBag.errorMessage = "Error occurred while processing your request.";
                    var _existinglangList = db.SP_SelectLanguages();
                    return(View(_existinglangList));
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Account"));
            }
        }
Beispiel #6
0
 public ActionResult Create(FormCollection collection)
 {
     if (Session["LogedUserID"] != null)
     {
         var zipcode   = "";
         var zipcodeid = "";
         ViewBag.successMessage = "";
         ViewBag.errorMessage   = "";
         try
         {
             var action = Request.Form["action"].ToString();
             if (action == "create")
             {
                 zipcode = Request.Form["zipname"].ToString();
                 var zip = (
                     from p in db.Zips
                     where (p.zipName == zipcode && p.active == true)
                     select p
                     ).FirstOrDefault();
                 if (zip != null)
                 {
                     ViewBag.successMessage = "";
                     ViewBag.errorMessage   = "ZipCode already exists";
                 }
                 if (zip == null)
                 {
                     db.SP_AddZipCode(zipcode, Session["LogedUserID"].ToString());
                     db.SaveChanges();
                     ViewBag.successMessage = "Record has been saved successfully";
                     ViewBag.errorMessage   = "";
                 }
             }
             if (action == "edit")
             {
                 zipcodeid = Request.Form["id"].ToString();
                 zipcode   = Request.Form["zipname"].ToString();
                 //var zip = (
                 //               from p in db.ZipCode
                 //               where (p.zipName == zipcode && p.active == true)
                 //               select p
                 //           ).FirstOrDefault();
                 //if (zip != null)
                 //{
                 //    ViewBag.successMessage = "";
                 //    ViewBag.errorMessage = "ZipCode already exists";
                 //    //var _existingallergyList = db.SP_SelectAllergy();
                 //    //return View(_existingallergyList);
                 //}
                 //if (zip == null)
                 //{
                 db.sp_UpdateZipCode(Convert.ToInt64(zipcodeid), zipcode, Session["LogedUserID"].ToString(), System.DateTime.Now);
                 db.SaveChanges();
                 ViewBag.successMessage = "Record has been saved successfully";
                 ViewBag.errorMessage   = "";
                 //}
             }
             if (action == "delete")
             {
                 zipcodeid = Request.Form["id"].ToString();
                 db.sp_DeleteZipCode(Convert.ToInt64(zipcodeid), Session["LogedUserID"].ToString(), System.DateTime.Now);
                 db.SaveChanges();
                 ViewBag.successMessage = "Record has been deleted successfully";
                 ViewBag.errorMessage   = "";
             }
             var __existingzipList = db.SP_SelectZipCode();
             return(View(__existingzipList));
         }
         catch (Exception ex)
         {
             ViewBag.errorMessage = "Error occurred while processing your request.";
             var _existingzipList = db.SP_SelectZipCode();
             return(View(_existingzipList));
         }
     }
     else
     {
         return(RedirectToAction("AdminLogin", "Account"));
     }
 }
Beispiel #7
0
        public async System.Threading.Tasks.Task <ActionResult> Create(FormCollection collection)
        {
            if (Session["LogedUserID"] != null)
            {
                var rolename = "";
                var desc     = "";
                var roleid   = "";
                ViewBag.successMessage = "";
                ViewBag.errorMessage   = "";
                try
                {
                    var action = Request.Form["action"].ToString();
                    if (action == "create")
                    {
                        rolename = Request.Form["rolename"].ToString();
                        desc     = Request.Form["desc"].ToString();

                        var role = new RoleManager <IdentityRole>(
                            new RoleStore <IdentityRole>(new ApplicationDbContext()));
                        if (!(role.RoleExists(rolename)))
                        {
                            var rm = new RoleManager <ApplicationRole>(

                                new RoleStore <ApplicationRole>(new ApplicationDbContext()));

                            var idResult = rm.Create(new ApplicationRole(rolename));
                            if (idResult.Succeeded)
                            {
                                AspNetRole thisRole = db.AspNetRoles.Where(r => r.Name.Equals(rolename, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                                thisRole.Description     = desc;
                                db.Entry(thisRole).State = EntityState.Modified;
                                db.SaveChanges();
                            }

                            ViewBag.successMessage = "Record has been saved successfully";
                            ViewBag.errorMessage   = "";
                        }
                        else
                        {
                            ViewBag.errorMessage   = "Role already exists.";
                            ViewBag.successMessage = "";
                        }
                    }
                    if (action == "edit")
                    {
                        //roleid = Request.Form["id"].ToString();
                        rolename = Request.Form["rolename"].ToString();
                        desc     = Request.Form["desc"].ToString();
                        AspNetRole thisRole = db.AspNetRoles.Where(r => r.Name.Equals(rolename, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                        thisRole.Description     = desc;
                        thisRole.Name            = rolename;
                        db.Entry(thisRole).State = EntityState.Modified;
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been saved successfully";
                        ViewBag.errorMessage   = "";
                        var _existingroleList = db.AspNetRoles.ToList();
                        return(View(_existingroleList));
                    }
                    if (action == "delete")
                    {
                        roleid = Request.Form["id"].ToString();
                        AspNetRole thisRole = db.AspNetRoles.Where(r => r.Id.Equals(roleid, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                        db.AspNetRoles.Remove(thisRole);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been deleted successfully";
                        ViewBag.errorMessage   = "";
                    }
                    var __existingroleList = db.SP_SelectRole();
                    return(View(__existingroleList));
                }
                catch (Exception ex)
                {
                    ViewBag.errorMessage = "Error occurred while processing your request.";
                    var _existingroleList = db.SP_SelectRole();
                    return(View(_existingroleList));
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Account"));
            }
        }
        public HttpResponseMessage PostDoctorTiming(DoctorTimingsModel doctorTimingModel)
        {
            if (doctorTimingModel.from.Contains("PM"))
            {
                if (doctorTimingModel.to.Contains("AM"))
                {
                    //return BadRequest("Timings should be within single day.");
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Timings should be within single day."
                    });
                    response.ReasonPhrase = "Timings should be within single day.";
                    return(response);
                }
            }
            if (doctorTimingModel.from == doctorTimingModel.to)
            {
                //return BadRequest("From Time and To Time can not be same.");
                response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                    ID = 0, message = "From Time and To Time can not be same."
                });
                response.ReasonPhrase = "From Time and To Time can not be same.";
                return(response);
            }
            if (DateTime.ParseExact(doctorTimingModel.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay <
                DateTime.ParseExact(doctorTimingModel.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay)
            {
                //return BadRequest("From Time can not be greater than To Time.");
                response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                    ID = 0, message = "From Time can not be greater than To Time."
                });
                response.ReasonPhrase = "From Time can not be greater than To Time.";
                return(response);
            }
            TimeSpan diff = DateTime.ParseExact(doctorTimingModel.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay -
                            DateTime.ParseExact(doctorTimingModel.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;

            if (diff.TotalMinutes < 15)
            {
                //return BadRequest("Timespan less than 15 minutes is not allowed.");
                response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                    ID = 0, message = "Timespan less than 15 minutes is not allowed."
                });
                response.ReasonPhrase = "Timespan less than 15 minutes is not allowed.";
                return(response);
            }
            var          doctorTiming = new DoctorTiming();
            var          timingsList  = GetDoctorTimingByDoctorId(doctorTimingModel.doctorID);
            var          timezoneid   = db.Doctors.Where(d => d.doctorID == doctorTimingModel.doctorID).Select(d => d.timezone).FirstOrDefault();
            TimeZoneInfo zoneInfo     = TimeZoneInfo.FindSystemTimeZoneById(timezoneid.ToString());

            foreach (var y in timingsList)
            {
                DateTime?from = DateTime.UtcNow.Date;
                from   = from + DateTime.ParseExact(y.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;
                from   = TimeZoneInfo.ConvertTimeFromUtc(from.Value, zoneInfo);
                y.from = from.Value.ToString("hh:mm tt", CultureInfo.InvariantCulture);

                DateTime?to = DateTime.UtcNow.Date;
                to   = to + DateTime.ParseExact(y.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;
                to   = TimeZoneInfo.ConvertTimeFromUtc(to.Value, zoneInfo);
                y.to = to.Value.ToString("hh:mm tt", CultureInfo.InvariantCulture);
            }
            DateTime fromtimeUTC = DateTime.ParseExact(doctorTimingModel.from,
                                                       "hh:mm tt", CultureInfo.InvariantCulture);
            //fromtimeUTC = TimeZoneInfo.ConvertTimeToUtc(fromtimeUTC,zoneInfo);
            DateTime totimeUTC = DateTime.ParseExact(doctorTimingModel.to,
                                                     "hh:mm tt", CultureInfo.InvariantCulture);
            //totimeUTC = TimeZoneInfo.ConvertTimeToUtc(totimeUTC, zoneInfo);

            var alreadItems = timingsList
                              .Where(o => o.day == doctorTimingModel.day &&
                                     (o.from == fromtimeUTC.ToString("hh:mm tt") || o.to == totimeUTC.ToString("hh:mm tt")
                                      ||
                                      (
                                          fromtimeUTC.TimeOfDay >=
                                          DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
                                          &&
                                          fromtimeUTC.TimeOfDay <
                                          DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay

                                      )
                                      ||
                                      (
                                          totimeUTC.TimeOfDay >
                                          DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
                                          &&
                                          totimeUTC.TimeOfDay <=
                                          DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
                                      )

                                      ||
                                      (
                                          fromtimeUTC.TimeOfDay <=
                                          DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
                                          &&
                                          totimeUTC.TimeOfDay >=
                                          DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
                                      )
                                      ||
                                      (
                                          fromtimeUTC <
                                          DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture)
                                          &&
                                          totimeUTC >=
                                          DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture)
                                      )
                                     )).ToList();
            //var alreadItems = timingsList
            //    .Where(o => o.day == doctorTimingModel.day &&
            //    (o.from == doctorTimingModel.from || o.to == doctorTimingModel.to
            //    ||
            //    (
            //    DateTime.ParseExact(doctorTimingModel.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay >=
            //    DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
            //    &&
            //    DateTime.ParseExact(doctorTimingModel.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay <=
            //    DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay

            //    )
            //    ||
            //    (
            //    DateTime.ParseExact(doctorTimingModel.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay >=
            //    DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
            //    &&
            //    DateTime.ParseExact(doctorTimingModel.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay <=
            //    DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
            //    )

            //    ||
            //    (
            //    DateTime.ParseExact(doctorTimingModel.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay <=
            //    DateTime.ParseExact(o.from, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
            //    &&
            //    DateTime.ParseExact(doctorTimingModel.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay >=
            //    DateTime.ParseExact(o.to, "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay
            //    )

            //    )).ToList();

            var chkpmtoam = alreadItems.Where(x => x.from.Contains("PM") && x.to.Contains("AM")).FirstOrDefault();
            //var otherthanpmtoam = alreadItems.Where(x => !(x.from.Contains("PM")) && !(x.to.Contains("AM"))).FirstOrDefault();
            var flag = 0;

            foreach (var t in alreadItems)
            {
                if (t.from.Contains("AM") && t.to.Contains("AM") ||
                    t.from.Contains("PM") && t.to.Contains("PM") ||
                    t.from.Contains("AM") && t.to.Contains("PM"))
                {
                    flag = 1;
                    break;
                }
            }
            if (alreadItems.Count > 0)
            {
                if (flag == 1)
                {
                    //return BadRequest("Timings can not be overlapped across each other.");
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Timings can not be overlapped across each other."
                    });
                    response.ReasonPhrase = "Timings can not be overlapped across each other.";
                    return(response);
                }
                //return CreatedAtRoute("DefaultApi", new { message = "Timings can not be overlapped across each other" }, doctorTiming);
            }

            if (!ModelState.IsValid)
            {
                //return BadRequest(ModelState);
                response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                    ID = 0, message = "Model is not valid."
                });
                response.ReasonPhrase = "Model is not valid.";
                return(response);
            }
            try
            {
                doctorTiming.doctorID        = doctorTimingModel.doctorID;
                doctorTiming.doctorTimingsID = 0;
                doctorTiming.day             = doctorTimingModel.day;

                string nextDay = "";
                if (doctorTimingModel.day.ToString().ToLower().Equals("monday"))
                {
                    nextDay = "Tuesday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("tuesday"))
                {
                    nextDay = "Wednesday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("wednesday"))
                {
                    nextDay = "Thursday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("thursday"))
                {
                    nextDay = "Friday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("friday"))
                {
                    nextDay = "Saturday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("saturday"))
                {
                    nextDay = "Sunday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("Sunday"))
                {
                    nextDay = "Monday";
                }

                string prevDay = "";
                if (doctorTimingModel.day.ToString().ToLower().Equals("monday"))
                {
                    prevDay = "Sunday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("tuesday"))
                {
                    prevDay = "Monday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("wednesday"))
                {
                    prevDay = "tuesday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("thursday"))
                {
                    prevDay = "Wednesday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("friday"))
                {
                    prevDay = "Thursday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("saturday"))
                {
                    prevDay = "Friday";
                }
                else if (doctorTimingModel.day.ToString().ToLower().Equals("Sunday"))
                {
                    prevDay = "Saturday";
                }

                DateTime dateTimeFrom = DateTime.ParseExact(doctorTimingModel.from,
                                                            "hh:mm tt", CultureInfo.InvariantCulture);
                DateTime dateTimeTo = DateTime.ParseExact(doctorTimingModel.to,
                                                          "hh:mm tt", CultureInfo.InvariantCulture);

                //For DayLightTimeSaving Issue at mobile devices
                TimeSpan ts         = new TimeSpan(0, 0, 60, 0);
                bool     isDaylight = zoneInfo.IsDaylightSavingTime(dateTimeFrom);

                /*   if (isDaylight)
                 * {
                 *     doctorTiming.from = TimeZoneInfo.ConvertTimeToUtc(dateTimeFrom, zoneInfo).Add(ts).TimeOfDay;
                 *     doctorTiming.to = TimeZoneInfo.ConvertTimeToUtc(dateTimeTo, zoneInfo).Add(ts).TimeOfDay;
                 * }
                 * else
                 * {
                 *     doctorTiming.from = TimeZoneInfo.ConvertTimeToUtc(dateTimeFrom, zoneInfo).TimeOfDay;
                 *     doctorTiming.to = TimeZoneInfo.ConvertTimeToUtc(dateTimeTo, zoneInfo).TimeOfDay;
                 * }*/
                DateTime from = TimeZoneInfo.ConvertTimeToUtc(dateTimeFrom, zoneInfo);
                DateTime to   = TimeZoneInfo.ConvertTimeToUtc(dateTimeTo, zoneInfo);
                doctorTiming.from = from.TimeOfDay;
                doctorTiming.to   = to.TimeOfDay;
                if (from.Date > dateTimeFrom.Date)
                {
                    doctorTiming.utcDay = nextDay;
                }
                else if (from.Date < dateTimeFrom.Date)
                {
                    doctorTiming.utcDay = prevDay;
                }
                else
                {
                    doctorTiming.utcDay = doctorTimingModel.day;
                }
                doctorTiming.active = true;
                doctorTiming.cd     = DateTime.Now;
                doctorTiming.md     = DateTime.Now;
                doctorTiming.cb     = doctorTimingModel.username;

                db.DoctorTimings.Add(doctorTiming);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                //return BadRequest(ex.Message);
                response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                    ID = 0, message = ex.Message
                });
                response.ReasonPhrase = ex.Message;
                return(response);
            }


            //return CreatedAtRoute("DefaultApi", new { id = doctorTiming.doctorTimingsID }, doctorTiming);
            response = Request.CreateResponse(HttpStatusCode.OK, new { id = doctorTiming.doctorTimingsID, doctorTiming });
            return(response);
        }
Beispiel #9
0
        public async System.Threading.Tasks.Task <ActionResult> Create(FormCollection collection)
        {
            if (Session["LogedUserID"] != null)
            {
                ViewBag.successMessage = "";
                ViewBag.errorMessage   = "";

                var  id         = "";
                var  userid     = "";
                var  firstName  = "";
                var  lastName   = "";
                var  email      = "";
                var  password   = "";
                bool isAllValid = true;

                try
                {
                    var action = Request.Form["action"].ToString();
                    if (action == "create")
                    {
                        firstName = Request.Form["firstName"].ToString();
                        lastName  = Request.Form["lastName"].ToString();
                        email     = Request.Form["email"].ToString();
                        password  = Request.Form["password"].ToString();
                        if (!Regex.IsMatch(firstName, @"^[a-zA-Z\s]+$"))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid First Name";
                            var _existingdList = db.SP_SelectDoctor();
                            return(View(_existingdList));
                        }
                        if (!Regex.IsMatch(lastName, @"^[a-zA-Z\s]+$"))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid Last Name";
                            var _existingdList = db.SP_SelectDoctor();
                            return(View(_existingdList));
                        }
                        Utility util = new Utility();
                        if (!(util.IsValid(email)))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid Email Address";
                            var _existingdList = db.SP_SelectDoctor();
                            return(View(_existingdList));
                        }

                        //db.SP_AddDoctor(firstName, lastName, email, password, Session["LogedUserID"].ToString());
                        //db.SaveChanges();
                        var user = new ApplicationUser
                        {
                            UserName  = email,
                            Email     = email,
                            FirstName = firstName,
                            LastName  = lastName,
                        };
                        var result = await UserManager.CreateAsync(user, password);

                        if (result.Succeeded)
                        {
                            var doctor = new DataAccess.Doctor();
                            doctor.userId    = user.Id;
                            doctor.lastName  = user.LastName;
                            doctor.firstName = user.FirstName;
                            doctor.email     = user.Email;
                            doctor.cb        = Session["LogedUserID"].ToString();
                            doctor.active    = true;
                            doctor.status    = false;
                            db.Doctors.Add(doctor);
                            db.SaveChanges();

                            var userAssignRole = new UserAssignRoleModel();
                            userAssignRole.UserId = user.Id;//"8466ba63-b903-4d0a-8633-ce399ed1b542";//
                            userAssignRole.Role   = "Doctor";


                            var     strContent = JsonConvert.SerializeObject(userAssignRole);
                            var     response   = ApiConsumerHelper.PostData("api/Roles/AssignRole", strContent);
                            dynamic resultAdd  = JsonConvert.DeserializeObject(response);
                            ViewBag.successMessage = "Record has been saved successfully";
                            ViewBag.errorMessage   = "";
                        }
                        else
                        {
                            ViewBag.successMessage = "";
                            foreach (var error in result.Errors)
                            {
                                ViewBag.errorMessage = error;
                            }
                            var _existingdList = db.SP_SelectDoctor();
                            return(View(_existingdList));
                        }
                    }
                    if (action == "edit")
                    {
                        id       = Request.Form["id"].ToString();
                        userid   = Request.Form["userid"].ToString();
                        password = Request.Form["password"].ToString();
                        string token = await UserManager.GeneratePasswordResetTokenAsync(userid);

                        //var firstName = Request.Form["firstName"].ToString();
                        //var lastName = Request.Form["lastName"].ToString();
                        //var email = Request.Form["email"].ToString();
                        //db.sp_ResetDoctorPassword(Convert.ToInt64(id), password, Session["LogedUserID"].ToString(), System.DateTime.Now);
                        //db.SaveChanges();
                        var result = await UserManager.ResetPasswordAsync(userid, token, password);

                        if (result.Succeeded)
                        {
                            ViewBag.successMessage = "Record has been saved successfully";
                            ViewBag.errorMessage   = "";
                        }
                        else
                        {
                            ViewBag.successMessage = "";
                            foreach (var error in result.Errors)
                            {
                                ViewBag.errorMessage = error;
                            }
                            var _existingdList = db.SP_SelectDoctor();
                            return(View(_existingdList));
                        }
                    }
                    if (action == "delete")
                    {
                        id     = Request.Form["id"].ToString();
                        userid = Request.Form["userid"].ToString();
                        Doctor doc = db.Doctors.Where(a => a.userId == userid).FirstOrDefault();
                        if (doc != null)
                        {
                            doc.active          = false;
                            doc.mb              = Session["LogedUserID"].ToString();
                            doc.md              = DateTime.Now;
                            db.Entry(doc).State = EntityState.Modified;
                            db.SaveChanges();
                            ViewBag.successMessage = "Record has been deleted successfully";
                            ViewBag.errorMessage   = "";
                        }
                        else
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Doctor not found.";
                        }
                    }


                    var _existingdoctorsList = db.SP_SelectDoctor();
                    return(View(_existingdoctorsList));
                }
                catch (Exception ex)
                {
                    ViewBag.errorMessage = "Error occurred while processing your request.";
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Account"));
            }
        }
 public ActionResult Create(FormCollection collection)
 {
     if (Session["LogedUserID"] != null)
     {
         var specialityid    = "";
         var doctorid        = "";
         var docspecialityid = "";
         ViewBag.successMessage = "";
         ViewBag.errorMessage   = "";
         try
         {
             var action = Request.Form["action"].ToString();
             if (action == "create")
             {
                 specialityid = Request.Form["sltspeciality"].ToString();
                 doctorid     = Request.Form["sltdoctor"].ToString();
                 db.SP_AddDoctorSpeciality(Convert.ToInt64(doctorid), Convert.ToInt64(specialityid), Session["LogedUserID"].ToString());
                 db.SaveChanges();
                 ViewBag.successMessage = "Record has been saved successfully";
                 ViewBag.errorMessage   = "";
             }
             if (action == "edit")
             {
                 docspecialityid = Request.Form["id"].ToString();
                 specialityid    = Request.Form["sltspeciality"].ToString();
                 doctorid        = Request.Form["sltdoctor"].ToString();
                 db.sp_UpdateDoctorSpeciality(Convert.ToInt64(docspecialityid), Convert.ToInt64(doctorid), Convert.ToInt64(specialityid), Session["LogedUserID"].ToString(), System.DateTime.Now);
                 db.SaveChanges();
                 ViewBag.successMessage = "Record has been saved successfully";
                 ViewBag.errorMessage   = "";
                 //}
             }
             if (action == "delete")
             {
                 docspecialityid = Request.Form["id"].ToString();
                 db.sp_DeleteDoctorSpeciality(Convert.ToInt64(docspecialityid), Session["LogedUserID"].ToString(), System.DateTime.Now);
                 db.SaveChanges();
                 ViewBag.successMessage = "Record has been deleted successfully";
                 ViewBag.errorMessage   = "";
             }
             var __existingdocspeList = db.SP_SelectDoctorSpeciality();
             var doctors = db.Doctors
                           .Where(a => a.active == true).ToList();
             ViewBag.Doctors = doctors;
             var speciality = db.Speciallities
                              .Where(a => a.active == true).ToList();
             ViewBag.Speciality = speciality;
             return(View(__existingdocspeList));
         }
         catch (Exception ex)
         {
             ViewBag.errorMessage = "Error occurred while processing your request.";
             var __existingdocspeList = db.SP_SelectDoctorSpeciality();
             var doctors = db.Doctors
                           .Where(a => a.active == true).ToList();
             ViewBag.Doctors = doctors;
             var speciality = db.Speciallities
                              .Where(a => a.active == true).ToList();
             ViewBag.Speciality = speciality;
             return(View(__existingdocspeList));
         }
     }
     else
     {
         return(RedirectToAction("../Login/Index"));
     }
 }
Beispiel #11
0
        public HttpResponseMessage GetPatientDoseSpotUrl(long patientId)
        {
            try
            {
                //Search if patient contains doseSpot Id
                var oPatientInfo = db.Patients.FirstOrDefault(x => x.patientID == patientId);

                int?DoseSpotPatientId = null;
                if (oPatientInfo != null)
                {
                    var oDoseSpotPatientEntry = new DoseSpotPatientEntry
                    {
                        PatientId   = DoseSpotPatientId,
                        FirstName   = oPatientInfo.firstName,
                        LastName    = oPatientInfo.lastName,
                        MiddleName  = "",
                        Address1    = oPatientInfo.address1,
                        Address2    = oPatientInfo.address2,
                        City        = oPatientInfo.city,
                        State       = oPatientInfo.state,
                        ZipCode     = oPatientInfo.zip,
                        Gender      = oPatientInfo.gender,
                        Phone       = oPatientInfo.cellPhone,
                        DateOfBirth = oPatientInfo.dob.Value,
                        PharmacyId  = oPatientInfo.pharmacyid
                    };

                    if (string.IsNullOrEmpty(oPatientInfo.DoseSpotPatientId))
                    {
                        var oRet = DoseSpotHelper.RegisterPatientWithDoseSpot(oDoseSpotPatientEntry);

                        int DoseSpotPatId;
                        int.TryParse(oRet, out DoseSpotPatId);

                        if (DoseSpotPatId != 0)
                        {
                            oPatientInfo.DoseSpotPatientId = oRet;

                            db.Entry(oPatientInfo).State = EntityState.Modified;
                            db.SaveChanges();
                        }

                        oDoseSpotPatientEntry.PatientId = DoseSpotPatId;
                    }
                    else
                    {
                        oDoseSpotPatientEntry.PatientId = Convert.ToInt32(oPatientInfo.DoseSpotPatientId);
                    }

                    //Register Patient
                    var cFinalUrl = DoseSpotHelper.GetEPrescriptionUrl(oDoseSpotPatientEntry);
                    return(Request.CreateResponse(HttpStatusCode.OK, cFinalUrl));
                }

                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "This patient does not exists"));
            }
            catch (Exception ex)
            {
                //return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
                return(ThrowError(ex, "GetPatientDoseSpotUrl in DoseSpotController"));
            }
        }
Beispiel #12
0
        public ActionResult Create(FormCollection collection)
        {
            var  rovname = "";
            long rovid;

            ViewBag.successMessage = "";
            ViewBag.errorMessage   = "";
            try
            {
                var action = Request.Form["action"].ToString();
                if (action == "create")
                {
                    rovname = Request.Form["rovname"].ToString();
                    var obj_rov = (
                        from p in db.ROVs
                        where (p.name == rovname && p.active == true)
                        select p
                        ).FirstOrDefault();
                    if (obj_rov != null)
                    {
                        ViewBag.successMessage = "";
                        ViewBag.errorMessage   = "Reason of Visit already exists";
                    }
                    if (obj_rov == null)
                    {
                        ROV dbrov = new ROV();
                        dbrov.name   = rovname;
                        dbrov.cd     = DateTime.Now;
                        dbrov.cb     = SessionHandler.UserId;
                        dbrov.active = true;
                        db.ROVs.Add(dbrov);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been saved successfully";
                        ViewBag.errorMessage   = "";
                    }
                }
                if (action == "edit")
                {
                    rovid   = Convert.ToInt32(Request.Form["id"].ToString());
                    rovname = Request.Form["rovname"].ToString();
                    ROV dbrov = new ROV();
                    dbrov                 = db.ROVs.Where(r => r.rovID == rovid).FirstOrDefault();
                    dbrov.name            = rovname;
                    dbrov.md              = DateTime.Now;
                    dbrov.mb              = SessionHandler.UserId;
                    db.Entry(dbrov).State = EntityState.Modified;
                    db.SaveChanges();
                    ViewBag.successMessage = "Record has been saved successfully";
                    ViewBag.errorMessage   = "";
                }
                if (action == "delete")
                {
                    rovid = Convert.ToInt32(Request.Form["id"].ToString());
                    ROV dbrov = new ROV();
                    dbrov                 = db.ROVs.Where(r => r.rovID == rovid).FirstOrDefault();
                    dbrov.active          = false;
                    db.Entry(dbrov).State = EntityState.Modified;
                    db.SaveChanges();
                    ViewBag.successMessage = "Record has been deleted successfully";
                    ViewBag.errorMessage   = "";
                }
                var rov = db.ROVs.Where(r => r.active == true).ToList();
                return(View(rov));
            }
            catch (Exception ex)
            {
                ViewBag.errorMessage = "Error occurred while processing your request.";
                var _rov = db.ROVs.Where(r => r.active == true).ToList();
                return(View(_rov));
            }
        }
Beispiel #13
0
        public ActionResult Create(FormCollection collection)
        {
            var newsid     = "";
            var newstitle  = "";
            var newsdetail = "";

            byte[] thumbBytes   = null;
            byte[] detailBytes  = null;
            string thumbBase64  = "";
            string detailBase64 = "";

            ViewBag.successMessage = "";
            ViewBag.errorMessage   = "";
            if (Session["LogedUserID"] != null)
            {
                try
                {
                    var action = Request.Form["action"].ToString();
                    if (action == "create")
                    {
                        HttpPostedFileBase thumbnail   = Request.Files["thumbnailimage"];
                        HttpPostedFileBase detailimage = Request.Files["detailimage"];
                        newstitle    = Request.Form["newstitle"].ToString();
                        newsdetail   = Request.Form["newsdetail"].ToString();
                        thumbBytes   = util.ConvertToBytes(thumbnail);
                        detailBytes  = util.ConvertToBytes(detailimage);
                        thumbBase64  = "data:image/png;base64," + Convert.ToBase64String(thumbBytes);
                        detailBase64 = "data:image/png;base64," + Convert.ToBase64String(detailBytes);
                        var news = (
                            from p in db.News
                            where (p.newsTitle == newstitle || p.newsDetail == newsdetail && p.active == true)
                            select p
                            ).FirstOrDefault();
                        if (news != null)
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "News already exists";
                        }
                        if (news == null)
                        {
                            News newsObj = new News();
                            newsObj.active              = true;
                            newsObj.newsTitle           = newstitle;
                            newsObj.newsDetail          = newsdetail;
                            newsObj.newsThumbnailBase64 = thumbBase64;
                            newsObj.newsImageBase64     = detailBase64;
                            newsObj.cb = Session["LogedUserID"].ToString();
                            newsObj.cd = System.DateTime.UtcNow;
                            db.News.Add(newsObj);
                            db.SaveChanges();
                            //db.SP_AddNewss(newstitle, newsdetail, thumbBytes, detailBytes,Session["LogedUserID"].ToString());
                            //db.SaveChanges();
                            ViewBag.successMessage = "Record has been saved successfully";
                            ViewBag.errorMessage   = "";
                        }
                    }
                    if (action == "edit")
                    {
                        //HttpPostedFileBase thumbnail = Request.Files["tthumbnailimage"];
                        // HttpPostedFileBase detailimage = Request.Files["ddetailimage"];
                        if (Request.Files.Count == 2)
                        {
                            thumbBytes   = util.ConvertToBytes(Request.Files[0]);
                            detailBytes  = util.ConvertToBytes(Request.Files[1]);
                            thumbBase64  = "data:image/png;base64," + Convert.ToBase64String(thumbBytes);
                            detailBase64 = "data:image/png;base64," + Convert.ToBase64String(detailBytes);
                        }

                        newsid     = Request.Form["newsid"].ToString();
                        newstitle  = Request.Form["newstitle"].ToString();
                        newsdetail = Request.Form["newsdetail"].ToString();
                        long nid     = Convert.ToInt64(newsid);
                        News newsObj = new News();
                        newsObj = db.News.Where(n => n.newsID == nid && n.active == true).FirstOrDefault();
                        if (newsObj != null)
                        {
                            newsObj.active              = true;
                            newsObj.newsTitle           = newstitle;
                            newsObj.newsDetail          = newsdetail;
                            newsObj.newsThumbnailBase64 = thumbBase64;
                            newsObj.newsImageBase64     = detailBase64;
                            newsObj.mb = Session["LogedUserID"].ToString();
                            newsObj.md = System.DateTime.UtcNow;
                            db.Entry(newsObj).State = EntityState.Modified;
                            db.SaveChanges();
                        }

                        //db.sp_UpdateNews(Convert.ToInt64(newsid), newstitle, newsdetail, thumbBytes, detailBytes, Session["LogedUserID"].ToString(), System.DateTime.Now);
                        //db.SaveChanges();
                        ViewBag.successMessage = "Record has been saved successfully";
                        ViewBag.errorMessage   = "";
                    }
                    if (action == "delete")
                    {
                        newsid = Request.Form["newsid"].ToString();
                        db.sp_DeleteNews(Convert.ToInt64(newsid), Session["LogedUserID"].ToString(), System.DateTime.Now);
                        db.SaveChanges();
                        ViewBag.successMessage = "Record has been deleted successfully";
                        ViewBag.errorMessage   = "";
                    }
                    var __existingnewsList = db.SP_SelectNewss();
                    return(View(__existingnewsList));
                }
                catch (Exception ex)
                {
                    ViewBag.errorMessage = "Error occurred while processing your request.";
                    var _existingnewsList = db.SP_SelectNewss();
                    return(View(_existingnewsList));
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Account"));
            }
        }
Beispiel #14
0
        public async System.Threading.Tasks.Task <ActionResult> Create(FormCollection collection)
        {
            if (Session["LogedUserID"] != null)
            {
                ViewBag.successMessage = "";
                ViewBag.errorMessage   = "";
                var id        = "";
                var firstName = "";
                var lastName  = "";
                var email     = "";
                var password  = "";
                var roleID    = "";


                try
                {
                    var action = Request.Form["action"].ToString();
                    if (action == "create")
                    {
                        firstName = Request.Form["firstname"].ToString();
                        lastName  = Request.Form["lastname"].ToString();
                        email     = Request.Form["email"].ToString();
                        password  = Request.Form["password"].ToString();
                        //roleID = Request.Form["sltRole"].ToString();
                        var roles = db.AspNetRoles.ToList();
                        //if (roleID == "")
                        //{
                        //    ViewBag.successMessage = "";
                        //    ViewBag.errorMessage = "Select valid Role";
                        //    var _existingadminList = db.SP_SelectAdmin();
                        //    //var roles = db.Roles
                        //    //  .Where(a => a.active == true).ToList();

                        //    ViewBag.Roles = roles;
                        //    return View(_existingadminList);
                        //}
                        if (!Regex.IsMatch(firstName, @"^[a-zA-Z\s]+$"))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid First Name";
                            var _existingadminList = db.SP_SelectAdmin();
                            //var roles = db.Roles
                            //.Where(a => a.active == true).ToList();

                            ViewBag.Roles = roles;
                            return(View(_existingadminList));
                        }
                        if (!Regex.IsMatch(lastName, @"^[a-zA-Z\s]+$"))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid Last Name";
                            var _existingadminList = db.SP_SelectAdmin();
                            //var roles = db.Roles
                            //.Where(a => a.active == true).ToList();
                            ViewBag.Roles = roles;

                            return(View(_existingadminList));
                        }
                        Utility util = new Utility();
                        if (!(util.IsValid(email)))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid Email Address";
                            var _existingadminList = db.SP_SelectAdmin();
                            //var roles = db.Roles
                            //.Where(a => a.active == true).ToList();

                            ViewBag.Roles = roles;
                            return(View(_existingadminList));
                        }
                        var checkemail = (
                            from p in db.AdminUsers
                            where (p.email == email && p.active == true)
                            select p
                            ).FirstOrDefault();
                        if (checkemail == null)
                        {
                            var user = new ApplicationUser
                            {
                                UserName  = email,
                                Email     = email,
                                FirstName = firstName,
                                LastName  = lastName,
                            };
                            var result = await UserManager.CreateAsync(user, password);

                            if (result.Succeeded)
                            {
                                db.SP_AddAdmin(firstName, lastName, email, user.Id, Session["LogedUserID"].ToString());
                                db.SaveChanges();

                                var userAssignRole = new UserAssignRoleModel();
                                userAssignRole.UserId = user.Id;//"8466ba63-b903-4d0a-8633-ce399ed1b542";//
                                userAssignRole.Role   = "Admin";
                                var     strContent = JsonConvert.SerializeObject(userAssignRole);
                                var     response   = ApiConsumerHelper.PostData("api/Roles/AssignRole", strContent);
                                dynamic resultAdd  = JsonConvert.DeserializeObject(response);

                                ViewBag.successMessage = "Record has been saved successfully";
                                ViewBag.errorMessage   = "";
                            }
                            else
                            {
                                ViewBag.successMessage = "";
                                foreach (var error in result.Errors)
                                {
                                    ViewBag.errorMessage = error;
                                }

                                var _existingadminList = db.SP_SelectAdmin();
                                return(View(_existingadminList));
                            }
                        }
                        else
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "User with this Email Address already exists";
                            var _existingadminList = db.SP_SelectAdmin();
                            //var roles = db.Roles
                            //.Where(a => a.active == true).ToList();

                            ViewBag.Roles = roles;
                            return(View(_existingadminList));
                        }
                    }
                    if (action == "edit")
                    {
                        id        = Request.Form["id"].ToString();
                        firstName = Request.Form["firstName"].ToString();
                        lastName  = Request.Form["lastName"].ToString();
                        email     = Request.Form["email"].ToString();
                        password  = Request.Form["password"].ToString();
                        //roleID = Request.Form["sltRole"].ToString();
                        var rroles = db.AspNetRoles.ToList();
                        //if (roleID == "")
                        //{
                        //    ViewBag.successMessage = "";
                        //    ViewBag.errorMessage = "Select valid Role";
                        //    var _existingadminList = db.SP_SelectAdmin();
                        //    //var roles = db.Roles
                        //    //  .Where(a => a.active == true).ToList();

                        //    ViewBag.Roles = rroles;
                        //    return View(_existingadminList);
                        //}
                        if (!Regex.IsMatch(firstName, @"^[a-zA-Z\s]+$"))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid First Name";
                            var _existingadminList = db.SP_SelectAdmin();
                            //var roles = db.Roles
                            //  .Where(a => a.active == true).ToList();

                            ViewBag.Roles = rroles;
                            return(View(_existingadminList));
                        }
                        if (!Regex.IsMatch(lastName, @"^[a-zA-Z\s]+$"))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid Last Name";
                            var _existingadminList = db.SP_SelectAdmin();
                            // var roles = db.Roles
                            //.Where(a => a.active == true).ToList();

                            ViewBag.Roles = rroles;
                            return(View(_existingadminList));
                        }
                        Utility util = new Utility();
                        if (!(util.IsValid(email)))
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Provide valid Email Address";
                            var _existingadminList = db.SP_SelectAdmin();
                            // var roles = db.Roles
                            //.Where(a => a.active == true).ToList();

                            ViewBag.Roles = rroles;
                            return(View(_existingadminList));
                        }


                        var checkemail = (
                            from p in db.AspNetUsers
                            where (p.Email == email && p.Id != id)
                            select p
                            ).FirstOrDefault();
                        if (checkemail == null)
                        {
                            string token = await UserManager.GeneratePasswordResetTokenAsync(id);

                            var result = await UserManager.ResetPasswordAsync(id, token, password);

                            if (result.Succeeded)
                            {
                                AdminUser adminUser = db.AdminUsers.Where(a => a.userId == id).FirstOrDefault();
                                if (adminUser != null)
                                {
                                    //Update AdminUsers table
                                    adminUser.lastName  = lastName;
                                    adminUser.FirstName = firstName;
                                    adminUser.email     = email;
                                    adminUser.mb        = Session["LogedUserID"].ToString();
                                    adminUser.md        = DateTime.Now;
                                    db.AdminUsers.Add(adminUser);
                                    db.Entry(adminUser).State = EntityState.Modified;
                                }
                                //Update AspNetUsers table
                                AspNetUser aspnetUser = await db.AspNetUsers.FindAsync(id);

                                if (aspnetUser == null)
                                {
                                    ViewBag.successMessage = "";
                                    ViewBag.errorMessage   = "Admin user not found.";
                                    return(View());
                                }
                                aspnetUser.LastName  = lastName;
                                aspnetUser.FirstName = firstName;
                                aspnetUser.Email     = email;
                                db.AspNetUsers.Add(aspnetUser);
                                db.Entry(aspnetUser).State = EntityState.Modified;

                                await db.SaveChangesAsync();

                                ViewBag.successMessage = "Record has been saved successfully";
                                ViewBag.errorMessage   = "";
                            }
                            else
                            {
                                ViewBag.successMessage = "";
                                foreach (var error in result.Errors)
                                {
                                    ViewBag.errorMessage = error;
                                }
                                var _existingadminList = db.SP_SelectAdmin();
                                return(View(_existingadminList));
                            }
                        }
                        else
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "User with this Email Address already exists";
                            var _existingadminList = db.SP_SelectAdmin();
                            //var roles = db.Roles
                            //.Where(a => a.active == true).ToList();

                            ViewBag.Roles = rroles;
                            return(View(_existingadminList));
                        }
                    }
                    if (action == "delete")
                    {
                        id = Request.Form["id"].ToString();
                        var       userid    = Request.Form["userid"].ToString();
                        AdminUser adminUser = db.AdminUsers.Where(a => a.userId == userid).FirstOrDefault();
                        if (adminUser != null)
                        {
                            //Update AdminUsers table
                            adminUser.active          = false;
                            adminUser.mb              = Session["LogedUserID"].ToString();
                            adminUser.md              = DateTime.Now;
                            db.Entry(adminUser).State = EntityState.Modified;
                            db.SaveChanges();
                            ViewBag.successMessage = "Record has been deleted successfully";
                            ViewBag.errorMessage   = "";
                        }
                        //db.sp_DeleteAdmin(Convert.ToInt64(id), Session["LogedUserID"].ToString(), System.DateTime.Now);
                        //AspNetUser admin = db.AspNetUsers.Find(userid);

                        //db.AspNetUsers.Remove(admin);

                        //db.AspNetUsers.Remove(admin);
                        //db.SaveChanges();
                        else
                        {
                            ViewBag.successMessage = "";
                            ViewBag.errorMessage   = "Admin user not found.";
                        }
                    }
                    //Send Email//


                    //Send Email//
                    var __existingadminList = db.SP_SelectAdmin();
                    // var _roles = db.Roles
                    //.Where(a => a.active == true).ToList();
                    var _roles = db.AspNetRoles.ToList();
                    ViewBag.Roles = _roles;
                    return(View(__existingadminList));
                }
                catch (Exception ex)
                {
                    ViewBag.errorMessage = "Error occurred while processing your request.";
                    var _existingadminList = db.SP_SelectAdmin();
                    var roles = db.AspNetRoles.ToList();
                    ViewBag.Roles = roles;
                    return(View(_existingadminList));
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Account"));
            }
        }