Пример #1
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> CheckOldPassword(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(UMD.Project_ID);
            UserCEmailResponse Response = new UserCEmailResponse();

            try
            {
                List <MT_User> AnesList     = new List <MT_User>();
                Query          docRef       = Db.Collection("MT_User").WhereEqualTo("UM_Is_Deleted", false).WhereEqualTo("UM_Unique_ID", UMD.UM_Unique_ID).WhereEqualTo("UM_Password", UMD.UM_Password);
                QuerySnapshot  ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null && ObjQuerySnap.Documents.Count > 0)
                {
                    Response.Status       = con.StatusSuccess;
                    Response.Message      = con.MessageSuccess;
                    Response.Is_Available = true;
                }
                else
                {
                    Response.Status       = con.StatusAE;
                    Response.Message      = con.MessageAE;
                    Response.Is_Available = false;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #2
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> PatientResetPassword(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(Objuser.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "UM_Password", UMD.UM_Password }
                };
                DocumentReference docRef = Db.Collection("MT_User").Document(UMD.UM_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = UMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #3
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> GetDeletedList(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(UMD.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                List <MT_User> AnesList     = new List <MT_User>();
                Query          docRef       = Db.Collection("MT_User").WhereEqualTo("UM_Is_Deleted", true);
                QuerySnapshot  ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        AnesList.Add(Docsnapshot.ConvertTo <MT_User>());
                    }
                    Response.DataList = AnesList.OrderBy(o => o.UM_User_Name).ToList();
                }
                Response.Status  = con.StatusSuccess;
                Response.Message = con.MessageSuccess;
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #4
0
        public async Task <HttpResponseMessage> CreateAsync(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(UMD.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                UniqueID           = con.GetUniqueKey();
                UMD.UM_Unique_ID   = UniqueID;
                UMD.UM_Create_Date = con.ConvertTimeZone(UMD.UM_TimeZone, Convert.ToDateTime(UMD.UM_Create_Date));
                UMD.UM_Modify_Date = con.ConvertTimeZone(UMD.UM_TimeZone, Convert.ToDateTime(UMD.UM_Modify_Date));
                DocumentReference docRef = Db.Collection("MT_User").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(UMD);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = UMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #5
0
        public async Task <HttpResponseMessage> DeleteAsync(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(UMD.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                DocumentReference docRef = Db.Collection("MT_User").Document(UMD.UM_Unique_ID);
                WriteResult       Result = await docRef.DeleteAsync();

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = null;
                }
                else
                {
                    Response.Status  = con.StatusNotDeleted;
                    Response.Message = con.MessageNotDeleted;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #6
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> GetListFilterWithGroup(string groupname)
        {
            RightResponse Response = new RightResponse();

            try
            {
                MT_Right Equip = new MT_Right();
                MT_User  usr   = new MT_User();

                List <MT_Right> RightList    = new List <MT_Right>();
                Query           docRef       = Db.Collection("MT_Right").WhereEqualTo("RM_Is_Deleted", false).WhereEqualTo("RM_Category_Name", groupname);
                QuerySnapshot   ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        RightList.Add(Docsnapshot.ConvertTo <MT_Right>());
                    }
                    Response.DataList = RightList.OrderBy(o => o.RM_Category_Name).ThenBy(o => o.RM_Page_Name).ToList();
                }
                Response.Status  = con.StatusSuccess;
                Response.Message = con.MessageSuccess;
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #7
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> LoginAsync(MT_User Objuser)
        {
            //Db = con.SurgeryCenterDb(Objuser.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                MT_User       user       = new MT_User();
                Query         colref     = Db.Collection("MT_User").WhereEqualTo("UM_Is_Deleted", false).WhereEqualTo("UM_Is_Active", true);
                QuerySnapshot ObjDocSnap = await colref.GetSnapshotAsync();

                if (ObjDocSnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjDocSnap.Documents)
                    {
                        user = Docsnapshot.ConvertTo <MT_User>();
                        if (user != null)
                        {
                            if ((user.UM_Email.ToLower() == Objuser.UM_Email.ToLower() || user.UM_PhoneNo == Objuser.UM_PhoneNo) && user.UM_Password == Objuser.UM_Password)
                            {
                                Response.Data    = user;
                                Response.Status  = con.StatusSuccess;
                                Response.Message = con.MessageSuccess;
                            }
                        }
                        else
                        {
                            Response.Data    = null;
                            Response.Status  = con.StatusSuccess;
                            Response.Message = con.MessageSuccess;
                        }
                    }
                }
                else
                {
                    Response.Data    = null;
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #8
0
        public async Task <HttpResponseMessage> IsDeletedWithUMID(MT_User UMD)
        {
            UserResponse Response = new UserResponse();

            try
            {
                MT_User       user       = new MT_User();
                Query         UserQuery  = Db.Collection("MT_User").WhereEqualTo("UM_Is_Deleted", false).WhereEqualTo("UM_Member_ID", UMD.UM_Member_ID);
                QuerySnapshot ObjDocSnap = await UserQuery.GetSnapshotAsync();

                if (ObjDocSnap != null)
                {
                    user = ObjDocSnap.Documents[0].ConvertTo <MT_User>();
                    Dictionary <string, object> initialData = new Dictionary <string, object>
                    {
                        { "UM_Is_Deleted", UMD.UM_Is_Deleted }
                    };

                    DocumentReference docRef = Db.Collection("MT_User").Document(user.UM_Unique_ID);
                    WriteResult       Result = await docRef.UpdateAsync(initialData);

                    if (Result != null)
                    {
                        Response.Status  = con.StatusSuccess;
                        Response.Message = con.MessageSuccess;
                        Response.Data    = UMD;
                    }
                    else
                    {
                        Response.Status  = con.StatusNotUpdate;
                        Response.Message = con.MessageNotUpdate;
                        Response.Data    = null;
                    }
                }
                else
                {
                    Response.Status  = con.StatusDNE;
                    Response.Message = con.MessageDNE;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #9
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> ResetPass(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(Objuser.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                MT_User       User         = new MT_User();
                Query         QueryRef     = Db.Collection("MT_User").WhereEqualTo("UM_Email", UMD.UM_Email);
                QuerySnapshot ObjQuerySnap = await QueryRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    User = ObjQuerySnap.Documents[0].ConvertTo <MT_User>();
                }

                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "UM_Password", UMD.UM_Password }
                };
                DocumentReference docRef = Db.Collection("MT_User").Document(User.UM_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = UMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #10
0
        public async Task <HttpResponseMessage> UpdateAsync(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(UMD.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "UM_Password", UMD.UM_Password },
                    { "UM_Email", UMD.UM_Email },
                    { "UM_PhoneNo", UMD.UM_PhoneNo },
                    { "UM_Role_Type", UMD.UM_Role_Type },
                    { "UM_Is_Deleted", UMD.UM_Is_Deleted },
                    { "UM_Modify_Date", con.ConvertTimeZone(UMD.UM_TimeZone, Convert.ToDateTime(UMD.UM_Modify_Date)) },
                    { "UM_Is_Active", UMD.UM_Is_Active },
                    { "UM_Is_Deleted", UMD.UM_Is_Deleted }
                };
                DocumentReference docRef = Db.Collection("MT_User").Document(UMD.UM_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = UMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #11
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> TruncateUserMaster()
        {
            //Db = con.SurgeryCenterDb(UMD.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                MT_User             User         = new MT_User();
                CollectionReference docRef       = Db.Collection("MT_User");
                QuerySnapshot       ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        User = Docsnapshot.ConvertTo <MT_User>();
                        if (User.UM_Unique_ID != "28bLAlDi21ab1a937541a6")
                        {
                            DocumentReference DocRef = Db.Collection("MT_User").Document(User.UM_Unique_ID);
                            WriteResult       Result = await DocRef.DeleteAsync();

                            if (Result != null)
                            {
                                Response.Status  = con.StatusSuccess;
                                Response.Message = con.MessageSuccess;
                                Response.Data    = null;
                            }
                        }
                    }
                }
                Response.Status  = con.StatusSuccess;
                Response.Message = con.MessageSuccess;
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Пример #12
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> VarifyPasscode(MT_User Objuser)
        {
            //Db = con.SurgeryCenterDb(Objuser.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                MT_User       user       = new MT_User();
                Query         colref     = Db.Collection("MT_User").WhereEqualTo("UM_Is_Deleted", false).WhereEqualTo("UM_Is_Active", true).WhereEqualTo("UM_Passcode", Objuser.UM_Passcode).WhereEqualTo("UM_Unique_ID", Objuser.UM_Unique_ID);
                QuerySnapshot ObjDocSnap = await colref.GetSnapshotAsync();

                if (ObjDocSnap != null)
                {
                    user = ObjDocSnap.Documents[0].ConvertTo <MT_User>();
                    if (user.UM_Unique_ID != null)
                    {
                        Response.Status  = con.StatusSuccess;
                        Response.Message = con.MessageSuccess;
                    }
                    else
                    {
                        Response.Status  = con.StatusDNE;
                        Response.Message = con.MessageDNE;
                    }
                }
                else
                {
                    Response.Data    = null;
                    Response.Status  = con.StatusDNE;
                    Response.Message = con.MessageDNE;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = "Passcode Expired";
            }
            return(ConvertToJSON(Response));
        }
Пример #13
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> CheckEmail(MT_User UMD)
        {
            CommodelResponse Response = new CommodelResponse();
            Boolean          Result   = false;

            try
            {
                MT_User       User         = new MT_User();
                Query         docRef       = Db.Collection("MT_User").WhereEqualTo("UM_Is_Deleted", false).WhereEqualTo("UM_Is_Active", true).WhereEqualTo("UM_Email", UMD.UM_Email);
                QuerySnapshot ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    if (ObjQuerySnap.Documents.Count > 0)
                    {
                        Response.Where = "In User";
                        Result         = false;
                    }
                    else
                    {
                        Result = true;
                    }
                }
                else
                {
                    Result = true;
                }
                if (Result == true)
                {
                    docRef       = Db.Collection("MT_Staff_Members").WhereEqualTo("Staff_Is_Deleted", false).WhereEqualTo("Staff_Is_Active", true).WhereEqualTo("Staff_Email", UMD.UM_Email);
                    ObjQuerySnap = await docRef.GetSnapshotAsync();

                    if (ObjQuerySnap != null)
                    {
                        if (ObjQuerySnap.Documents.Count > 0)
                        {
                            Response.Where = "Staff";
                            Result         = false;
                        }
                        else
                        {
                            Result = true;
                        }
                    }
                    else
                    {
                        Result = true;
                    }
                }

                if (Result == true)
                {
                    docRef       = Db.Collection("MT_PatientInfomation").WhereEqualTo("Patient_Is_Deleted", false).WhereEqualTo("Patient_Is_Active", true).WhereEqualTo("Patient_Email", UMD.UM_Email);
                    ObjQuerySnap = await docRef.GetSnapshotAsync();

                    if (ObjQuerySnap != null)
                    {
                        if (ObjQuerySnap.Documents.Count > 0)
                        {
                            Response.Where = "Patient";
                            Result         = false;
                        }
                        else
                        {
                            Result = true;
                        }
                    }
                    else
                    {
                        Result = true;
                    }
                }
                Response.Result = Result;
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }