/// <summary>
        /// Gets the user feedbacks.
        /// </summary>
        /// <param name="userId">The user id.</param>
        /// <param name="subscriptionid">The subscriptionid.</param>
        /// <returns></returns>

        /*     internal IList<UserPOEMapping> GetUserFeedbacks(int userId, int subscriptionid)
         *   {
         *       using (var context = DataContextFactory.GetIntelliSetDataContext())
         *       {
         *           var results = context.GetUserFeedbacks(userId, subscriptionid);
         *           return results.SelectMany((a, b) => new List<UserPOEMapping>{
         *                new UserPOEMapping{
         *                    UserPOEMappingId = a.MappingId.GetValueOrDefault(),
         *                    AreaId = a.ZoneId.GetValueOrDefault(),
         *
         *                    //Designation = a.DesignationId.GetValueOrDefault(),
         *                    User = new User{
         *                        UserId = userId,
         *                        FirstName = a.FirstName,
         *                        LastName = a.LastName,
         *                        EmailAddress = a.EmailID,
         *                        Photo = a.Photo,
         *
         *                        Country = new Country{
         *                            Id = a.CountryId,
         *                                Name = Helper.GetCountryName(a.CountryId)
         *                        },
         *                        Area=  new Zone{
         *                            Id = a.ZoneId.GetValueOrDefault(),
         *                            Name = Helper.GetAreaById(a.ZoneId.GetValueOrDefault())
         *                        }
         *                    },
         *                    POE = new Util.Domain.POE() {
         *                        POEId = a.POEId,
         *                        Name = a.POEName,
         *                    },
         *                   Designation = new Designation{
         *                           DesignationId = a.DesignationId.GetValueOrDefault(),
         *                           Name = a.DesignationName,
         *                           Level = a.LevelId.GetValueOrDefault()
         *                   },
         *                   FeedbackDetails = new  Feedback{
         *                               FeedbackId = a.FeedbackId.GetValueOrDefault(),
         *                               RequestedBy = GetUserDetailsByMappingId(a.RequestedBy.GetValueOrDefault()),
         *                               RequestedFor = GetUserDetailsByMappingId(a.RequestedFor.GetValueOrDefault()),
         *                               RequestedFrom = GetUserDetailsByMappingId(a.RequestedFrom.GetValueOrDefault()),
         *                               CreatedOnDtm = a.FeedbackCreatedOn.GetValueOrDefault(),
         *                               UpdatedOnDtm = a.FeedbackUpdatedOn.GetValueOrDefault(),
         *                               CreatedOn = a.FeedbackCreatedOn!=null?a.FeedbackCreatedOn.GetValueOrDefault().ToString("MMMM dd, yyyy"):"",
         *                               UpdatedOn = a.FeedbackUpdatedOn!=null?a.FeedbackUpdatedOn.GetValueOrDefault().ToString("MMMM dd, yyyy"):"",
         *                               FeedbackStatus = (FeedbackStatus)Enum.Parse(typeof(FeedbackStatus),a.FeedBackStatus.GetValueOrDefault().ToString()),
         *                               FeedbackType = (FeedbackType)Enum.Parse(typeof(FeedbackType),a.FeedbackType.Value.ToString()),
         *                               GroupName = a.GroupName
         *                   },
         *
         *                   JobTitle = a.JobTitle
         *                }
         *           }).ToList();
         *       }
         *   }
         */
        /// <summary>
        /// Gets the received feedback.
        /// </summary>
        /// <param name="userId">The user id.</param>
        /// <param name="subscriptionid">The subscriptionid.</param>
        /// <returns></returns>

        /*    internal List<GetReceivedFeedbacksResult> GetReceivedFeedback(int userId, int subscriptionid)
         *  {
         *      using (var context = DataContextFactory.GetIntelliSetDataContext())
         *      {
         *          return context.GetReceivedFeedbacks(userId, subscriptionid).ToList();
         *      }
         *  }*/

        /// <summary>
        /// Gets the user details by mapping id.
        /// </summary>
        /// <param name="userMappingId">The user mapping id.</param>
        /// <returns></returns>
        internal UserPOEMapping GetUserDetailsByMappingId(int userMappingId)
        {
            using (var context = DataContextFactory.GetIntelliSetDataContext())
            {
                var userDetails = default(UserPOEMapping);

                var result = context.GetUserDetailsByMappingId(userMappingId).FirstOrDefault();
                if (result != null)
                {
                    userDetails = new UserPOEMapping
                    {
                        User = new User
                        {
                            FirstName      = result.FirstName,
                            LastName       = result.LastName,
                            EmailAddress   = result.EmailID,
                            Subscriptionid = result.SubscriptionID,
                            Country        = new Country
                            {
                                Id   = result.CountryId,
                                Name = Helper.GetCountryName(result.CountryId)
                            },
                            Area = new Zone
                            {
                                Id   = result.ZoneId.GetValueOrDefault(),
                                Name = Helper.GetAreaById(result.ZoneId.GetValueOrDefault())
                            }
                        },
                        AreaId = result.ZoneId.GetValueOrDefault(),
                        POE    = new Util.Domain.POE()
                        {
                            POEId = result.RoleId,
                            Name  = result.RoleTitle
                        },

                        //Role = new Role
                        //{
                        //    RoleId = result.RoleId,
                        //    Title = result.RoleTitle,
                        Designation = new Designation
                        {
                            DesignationId = result.DesignationId,
                            Level         = result.LevelId,
                            Name          = result.DesignationName,
                        },

                        JobTitle = result.JobTitle

                                   //}
                    };
                }
                return(userDetails);
            }
        }
Beispiel #2
0
        public IList <UserPOEMapping> GetFeedbackGiven(int userId, int subscriptionid)
        {
            //Log("WCF-GetFeedbackGiven-IN");
            var common = new Common.Common();

            using (var context = DataContextFactory.GetIntelliSetDataContext())
            {
                var results = context.GetFeedbackGiven(userId, subscriptionid);
                var outPut  = new List <UserPOEMapping>();
                //foreach (var b in results.GroupBy(item => item.GroupName).ToList())
                //{
                foreach (var a in results)
                {
                    if (a.FeedbackType != null)
                    {
                        var userPoeMapping = new UserPOEMapping
                        {
                            UserPOEMappingId = a.RequestedFor.GetValueOrDefault(),
                            AreaId           = a.ZoneId.GetValueOrDefault(),
                            User             = new User
                            {
                                UserId       = a.UserId.GetValueOrDefault(),
                                FirstName    = a.FirstName,
                                LastName     = a.LastName,
                                EmailAddress = a.EmailID,
                                //      Photo = a.Photo,

                                Country = new Country
                                {
                                    Id   = a.CountryId.GetValueOrDefault(),
                                    Name = Helper.GetCountryName(a.CountryId.GetValueOrDefault())
                                },
                                Area = new Zone
                                {
                                    Id   = a.ZoneId.GetValueOrDefault(),
                                    Name = Helper.GetAreaById(a.ZoneId.GetValueOrDefault())
                                }
                            },
                            POE = new Util.Domain.POE()
                            {
                                POEId = a.POEId.GetValueOrDefault(),
                                Name  = a.POEName,
                            },
                            Designation = new Designation
                            {
                                DesignationId = a.DesignationId.GetValueOrDefault(),
                                Name          = a.JobTitle,
                            },
                            FeedbackDetails = new Feedback
                            {
                                FeedbackId  = a.GroupName != null ? 0 : a.POEFeedbackId.GetValueOrDefault(),
                                RequestedBy =
                                    common.GetUserDetailsByMappingId(a.RequestedBy.GetValueOrDefault()),
                                RequestedFor =
                                    common.GetUserDetailsByMappingId(a.RequestedFor.GetValueOrDefault()),
                                RequestedFrom =
                                    common.GetUserDetailsByMappingId(a.RequestedFrom.GetValueOrDefault()),
                                RequestedById   = a.RequestedBy.GetValueOrDefault(),
                                RequestedForId  = a.RequestedFor.GetValueOrDefault(),
                                RequestedFromId = a.RequestedFrom.GetValueOrDefault(),
                                CreatedOnDtm    = a.CreatedOn.GetValueOrDefault(),
                                UpdatedOnDtm    = a.UpdatedOn.GetValueOrDefault(),
                                CreatedOn       =
                                    a.CreatedOn != null
                                        ? a.CreatedOn.GetValueOrDefault().ToString("MMMM dd, yyyy")
                                        : "",
                                UpdatedOn =
                                    a.UpdatedOn != null
                                        ? a.UpdatedOn.GetValueOrDefault().ToString("MMMM dd, yyyy")
                                        : "",
                                FeedbackStatus =
                                    (FeedbackStatus)
                                    Enum.Parse(typeof(FeedbackStatus),
                                               a.FeedbackStatus.GetValueOrDefault().ToString()),
                                FeedbackType =
                                    (FeedbackType)
                                    Enum.Parse(typeof(FeedbackType), a.FeedbackType.Value.ToString(CultureInfo.InvariantCulture)),
                                GroupName = a.GroupName
                            },

                            JobTitle = a.JobTitle
                        };
                        outPut.Add(userPoeMapping);

                        //if (userPoeMapping.FeedbackDetails.GroupName != null)
                        //{
                        //    userPoeMapping.Nooffbs = 1;
                        //    break;
                        //}
                    }
                }
                //}
                // Log("WCF-GetFeedbackGiven-OUT");
                return(outPut);
            }
        }