コード例 #1
0
        public async Task <VmGenericServiceResult> Insert(VmRatingItem vmRatingItem)
        {
            VmGenericServiceResult result = new VmGenericServiceResult();

            try
            {
                BudgetMetal.DBEntities.Rating r = new BudgetMetal.DBEntities.Rating();

                Copy <VmRatingItem, BudgetMetal.DBEntities.Rating>(vmRatingItem, r);

                if (r.CreatedBy.IsNullOrEmpty())
                {
                    r.CreatedBy = r.UpdatedBy = "System";
                }

                repo.Add(r);

                repo.Commit();

                result.IsSuccess     = true;
                result.MessageToUser = "******";
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Error     = e;
            }

            return(result);
        }
コード例 #2
0
        public async Task <VmRatingPage> GetRatingData(int page, int totalRecords, int companyId, int statusId = 0, string keyword = "")
        {
            var dbPageResult = await repo.GetRatingData((page == 0 ? Constants.app_firstPage : page), companyId,
                                                        (totalRecords == 0 ? Constants.app_totalRecords : totalRecords), keyword);


            if (dbPageResult == null)
            {
                return(new VmRatingPage());
            }

            var resultObj = new VmRatingPage();

            resultObj.RequestId      = DateTime.Now.ToString("yyyyMMddHHmmss");
            resultObj.RequestDate    = DateTime.Now;
            resultObj.Result         = new PageResult <VmRatingItem>();
            resultObj.Result.Records = new List <VmRatingItem>();

            Copy <PageResult <Com.BudgetMetal.DBEntities.Rating>, PageResult <VmRatingItem> >(dbPageResult, resultObj.Result, new string[] { "Records" });

            foreach (var dbItem in dbPageResult.Records)
            {
                var resultItem = new VmRatingItem();

                Copy <Com.BudgetMetal.DBEntities.Rating, VmRatingItem>(dbItem, resultItem);
                resultItem.UserName = dbItem.User.UserName;
                resultObj.Result.Records.Add(resultItem);
            }

            return(resultObj);
        }
コード例 #3
0
        public async Task <VmCompanyItem> GetCompanyProfileById(int Id)
        {
            var dbPageResult = await repo.Get(Id);

            if (dbPageResult == null)
            {
                return(new VmCompanyItem());
            }

            var resultObj = new VmCompanyItem();

            Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbPageResult, resultObj);

            resultObj.IsVerified = (dbPageResult.IsVerified == null) ? false : (bool)dbPageResult.IsVerified;

            var dbUserList = await repoUser.GetUserByCompanyNotFilterWithConfirm(Id);

            if (dbUserList == null)
            {
                return(resultObj);
            }

            resultObj.UserList = new List <VmUserItem>();

            foreach (var dbUser in dbUserList)
            {
                List <VmRoleItem> rListItem = new List <VmRoleItem>();
                if (dbUser.UserRoles != null)
                {
                    foreach (var dbRoleItem in dbUser.UserRoles)
                    {
                        var dbRole = roleRepository.Get(dbRoleItem.Role_Id);
                        if (dbRole != null)
                        {
                            VmRoleItem rItem = new VmRoleItem();
                            rItem.Id   = dbRole.Result.Id;
                            rItem.Name = dbRole.Result.Name;
                            rItem.Code = dbRole.Result.Code;
                            rListItem.Add(rItem);
                        }
                    }
                }
                VmUserItem user = new VmUserItem()
                {
                    Id           = dbUser.Id,
                    UserName     = dbUser.UserName,
                    EmailAddress = dbUser.EmailAddress,
                    JobTitle     = dbUser.JobTitle,
                    UserType     = dbUser.UserType,
                    IsConfirmed  = dbUser.IsConfirmed,
                    IsActive     = dbUser.IsActive,
                    RoleList     = rListItem
                };

                resultObj.UserList.Add(user);
            }

            var dbRepoList = await ratingRepo.GetRagintByCompany(Id);

            if (dbRepoList == null)
            {
                return(resultObj);
            }

            resultObj.RatingList = new List <VmRatingItem>();
            foreach (var dbRating in dbRepoList)
            {
                VmRatingItem rating = new VmRatingItem()
                {
                    SpeedOfQuotation  = dbRating.SpeedOfQuotation,
                    SpeedofDelivery   = dbRating.SpeedofDelivery,
                    ServiceQuality    = dbRating.ServiceQuality,
                    Price             = dbRating.Price,
                    SpeedofProcessing = dbRating.SpeedofProcessing,
                    Payment           = dbRating.Payment,
                    Title             = dbRating.Title,
                    Description       = dbRating.Description,
                    Ratingcol         = dbRating.Ratingcol,
                    UserName          = dbRating.User.ContactName
                };
                //var rating = new VmRatingItem();
                //Copy<Com.BudgetMetal.DBEntities.Rating, VmRatingItem>(dbRating, rating);
                resultObj.RatingList.Add(rating);
            }

            return(resultObj);
        }