//No Authorization Set intentionally
        public IActionResult getInNewuser([FromBody] UserBasic newUser)
        {
            Hashing sai = new Hashing();

            newUser.PdSystem     = sai.HashingPlain(newUser.PdSystem);
            newUser.UserIdSystem = Guid.NewGuid().ToString();
            string    msg     = string.Empty;
            bool      success = false;
            UserBasic user    = newUser;

            if (db.UserBasic.Where(x => x.Email.ToLower() == newUser.Email.ToLower()).Any())
            {
                msg = "User Already Exists. Please contact the Admin";
            }
            else
            {
                db.UserBasic.Add(newUser);
                db.SaveChanges();
                success = true;
                msg     = "Your Request has been submitted, Email confirmation will be sent up on approval. Thanks";
                AuthSession.SetUserId(HttpContext, newUser.UserIdSystem);
            }
            var result = new { success = success, msg = msg };

            return(Json(result));
        }
示例#2
0
        public IActionResult ManageProfile([FromBody] ProfileDetails profileDetails)
        {
            try
            {
                string    userId    = AuthSession.GetUserId(HttpContext, "userId");
                UserBasic userBasic = db.UserBasic.Where(x => x.UserIdSystem == userId).FirstOrDefault();
                if (profileDetails.ProfileId == 0)
                {
                    profileDetails.ProfileUserId        = Guid.NewGuid().ToString();
                    profileDetails.UpdatedDate          = DateTime.UtcNow;
                    profileDetails.UpdatedByName        = userBasic.FirstName + " " + userBasic.MiddleName + " " + userBasic.LastName;
                    profileDetails.UpdatedById          = userId;
                    profileDetails.MappedToUserIdSystem = userId;

                    db.ProfileDetails.Attach(profileDetails);
                    db.ProfileDetails.Add(profileDetails);
                }
                else
                {
                    ProfileDetails profileDetailsDb = db.ProfileDetails.Where(x => x.ProfileId == profileDetails.ProfileId).FirstOrDefault();
                    profileDetailsDb.FirstName   = profileDetails.FirstName;
                    profileDetailsDb.MiddleName  = profileDetails.MiddleName;
                    profileDetailsDb.LastName    = profileDetails.LastName;
                    profileDetailsDb.Gender      = profileDetails.Gender;
                    profileDetailsDb.Email       = profileDetails.Email;
                    profileDetailsDb.Phone       = profileDetails.Phone;
                    profileDetailsDb.City        = profileDetails.City;
                    profileDetailsDb.StateName   = profileDetails.StateName;
                    profileDetailsDb.Country     = profileDetails.Country;
                    profileDetailsDb.ZipCode     = profileDetails.ZipCode;
                    profileDetailsDb.Education   = profileDetails.Education;
                    profileDetailsDb.Profession  = profileDetails.Profession;
                    profileDetailsDb.Interest    = profileDetails.Interest;
                    profileDetailsDb.Expectation = profileDetails.Expectation;
                    profileDetailsDb.YearOfBirth = profileDetails.YearOfBirth;
                    profileDetailsDb.UpdatedDate = DateTime.UtcNow;
                    profileDetails.UpdatedByName = userBasic.FirstName + " " + userBasic.MiddleName + " " + userBasic.LastName;
                    profileDetails.UpdatedById   = userId;
                }
                db.SaveChanges();
                return(Json(new KeyValuePair <string, string>("y", "Profile Saved Successfully")));
            }
            catch (Exception)
            {
                return(Json(new KeyValuePair <string, string>("n", "Error saving profile, contact support")));
            }
        }
        public IActionResult ManageUserRole([FromBody] UserRoleMap userRoleDto)
        {
            string      key         = "n";
            string      value       = "Error Updating the User Role";
            string      userId      = AuthSession.GetUserId(HttpContext, "userId");
            UserRoleMap userRoleMap = new UserRoleMap();

            try
            {
                if (userRoleDto != null)
                {
                    bool isUser = Int32.TryParse(userRoleDto.UserIdSystem, out int userid);
                    if (isUser)
                    {
                        UserBasic userBasic = db.UserBasic.Where(x => x.UserIdId == userid).FirstOrDefault();
                        userRoleMap = db.UserRoleMap.Where(x => x.UserIdSystem == userBasic.UserIdSystem).FirstOrDefault();
                        if (userRoleMap != null)
                        {
                            db.UserRoleMap.Remove(userRoleMap);
                        }
                        if (userRoleDto.MapId == 1)
                        {
                            userRoleMap = new UserRoleMap
                            {
                                UserIdSystem = userBasic.UserIdSystem,
                                IsAdmin      = userRoleDto.IsAdmin,
                                UpdateByName = userBasic.FirstName + " " + userBasic.MiddleName + " " + userBasic.LastName,
                                UpdateById   = userId,
                                UpdatedDate  = DateTime.UtcNow
                            };
                            db.UserRoleMap.Attach(userRoleMap);
                            db.UserRoleMap.Add(userRoleMap);
                        }
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                return(Json(new KeyValuePair <string, string>(key, value)));
            }
            return(Json(new KeyValuePair <string, string>("y", "Role Updated Successfully")));
        }
示例#4
0
        public KeyValuePair <bool, string> SetMatch(SaiMatrimonyDb db, string proposedFromUserId, string proposedToUserId, string actionType, int reviewId)
        {
            ProfileReview  profileReview = new ProfileReview();
            ProfileDetails fromUser      = db.ProfileDetails.Where(x => x.ProfileUserId == proposedFromUserId).FirstOrDefault();
            ProfileDetails toIdUser      = db.ProfileDetails.Where(x => x.ProfileUserId == proposedToUserId).FirstOrDefault();
            ProfileComment comment       = new ProfileComment();
            CommonFunction common        = new CommonFunction();
            string         commentText   = string.Empty;
            string         msg           = "";
            bool           result        = false;

            try
            {
                if (actionType == "makeproposal")
                {
                    profileReview.ProposedFromUserId    = proposedFromUserId;
                    profileReview.ProposedToUserId      = proposedToUserId;
                    profileReview.HasMadeProposal       = true;
                    profileReview.DateMadeProposal      = DateTime.UtcNow;
                    profileReview.HasAcceptedDiscussion = false;
                    profileReview.HasAcceptedProposal   = false;
                    profileReview.HasRejectedProposal   = false;

                    db.ProfileReview.Add(profileReview);
                    db.SaveChanges();

                    comment = new ProfileComment();
                    comment.ProfileReviewId   = profileReview.ProfileReviewId;
                    comment.CommentText       = common.GetName(fromUser) + " proposed to " + common.GetName(toIdUser);
                    comment.CommentByUserName = common.GetName(fromUser);
                    comment.CommentByUserId   = fromUser.ProfileUserId;
                    comment.CommentDate       = DateTime.UtcNow;
                    db.ProfileComment.Add(comment);

                    db.SaveChanges();
                    return(new KeyValuePair <bool, string>(true, "Proposal has been made, You will be notified once the Match accepts discussion or your proposal"));
                }

                var hasprofile = db.ProfileReview.Where(x => x.ProfileReviewId == reviewId);
                if (hasprofile.Any())
                {
                    profileReview = hasprofile.FirstOrDefault();
                }
                else
                {
                    return(new KeyValuePair <bool, string>(false, "System could not match the profile, Contact Support for details"));
                }

                if (actionType == "acceptdiscussion" & profileReview.HasMadeProposal)
                {
                    profileReview.HasAcceptedDiscussion  = true;
                    profileReview.DateAcceptedDiscussion = DateTime.UtcNow;
                    db.SaveChanges();
                    commentText = common.GetName(fromUser) + " accepted to discuss " + common.GetName(toIdUser);
                    result      = true;
                    msg         = "You have accepted to dicuss with the match";
                    //return new KeyValuePair<bool, string>(true, "You have accepted to dicuss with the match");
                }
                else if (actionType == "acceptproposal" & profileReview.HasMadeProposal)
                {
                    profileReview.HasAcceptedProposal  = true;
                    profileReview.DateAcceptedProposal = DateTime.UtcNow;
                    db.SaveChanges();
                    commentText = common.GetName(fromUser) + " accepted proposal " + common.GetName(toIdUser);
                    result      = true;
                    msg         = "You have accepted the proposal with the match";
                    //return new KeyValuePair<bool, string>(true, "Match has been accepted. You will no longer have access to other profiles");
                }
                else if (actionType == "rejectproposal" & profileReview.HasMadeProposal)
                {
                    profileReview.HasRejectedProposal  = true;
                    profileReview.DateRejectedProposal = DateTime.UtcNow;
                    db.SaveChanges();
                    commentText = common.GetName(fromUser) + " rejected proposal " + common.GetName(toIdUser);
                    result      = true;
                    msg         = "You have rejected the proposal with the match";
                    //return new KeyValuePair<bool, string>(true, "Match has not been accepted. You will no longer have access to this profile");
                }

                comment = new ProfileComment();
                comment.ProfileReviewId   = reviewId;
                comment.CommentText       = commentText;
                comment.CommentByUserName = common.GetName(fromUser);
                comment.CommentByUserId   = fromUser.ProfileUserId;
                comment.CommentDate       = DateTime.UtcNow;
                db.ProfileComment.Add(comment);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                string ex = e.Message;
                return(new KeyValuePair <bool, string>(false, "System could not match the profile, Contact Support for details"));
            }

            if (result)
            {
                return(new KeyValuePair <bool, string>(result, msg));
            }

            return(new KeyValuePair <bool, string>(false, "System could not match the profile, Contact Support for details"));
        }