コード例 #1
0
 private string GetPlaceName(object id)
 {
     try
     {
         using (Yetkilim.Web.Models.Ef.yetkilimDBContext db = new Yetkilim.Web.Models.Ef.yetkilimDBContext())
         {
             db.ChangeTracker.QueryTrackingBehavior    = QueryTrackingBehavior.NoTracking;
             db.ChangeTracker.AutoDetectChangesEnabled = false;
             var id1  = (int)id;
             var name = db.Places.AsNoTracking().First(x => x.Id == id1).Name;
             return(name);
         }
     }
     catch (Exception ex)
     {
         return("");
     }
 }
コード例 #2
0
    public IActionResult FeedbackIndex()
    {
        var table  = string.Empty;
        int?userId = (int?)base.CurrentUser.UserId;

        if (!userId.HasValue)
        {
            return(RedirectToAction(controllerName: "Account", actionName: "Profile"));
        }

        using (Yetkilim.Web.Models.Ef.yetkilimDBContext db = new Yetkilim.Web.Models.Ef.yetkilimDBContext())
        {
            db.ChangeTracker.QueryTrackingBehavior    = QueryTrackingBehavior.NoTracking;
            db.ChangeTracker.AutoDetectChangesEnabled = false;
            //db.ProxyCreationEnabled = false;
            if (db.Feedback0.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback0.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "0");
            }
            if (db.Feedback1.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback1.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "1");
            }
            if (db.Feedback2.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback2.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "2");
            }
            if (db.Feedback3.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback3.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "3");
            }
            if (db.Feedback4.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback4.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "4");
            }
            if (db.Feedback5.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback5.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "5");
            }
            if (db.Feedback6.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback6.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "6");
            }
            if (db.Feedback7.Any(x => x.UserId == userId))
            {
                table += "<hr/>";
                table  = myTableMaker(db.Feedback7.AsNoTracking().Where(x => x.UserId == userId).ToArray(), "7");
            }
        }

        ViewBag.WarningDemo = string.IsNullOrWhiteSpace(table) ?  "Hiç Değerlendirme Yapılmamış" : null;

        ViewBag.Table = table;

        return(View());
    }
コード例 #3
0
        public async Task <IActionResult> Index()
        {
            try
            {
                CompanyFeedbacksModel model = new CompanyFeedbacksModel();
                var table         = string.Empty;
                var feedbackCount = 0;
                //var feedbackCount = 0;

                using (Yetkilim.Web.Models.Ef.yetkilimDBContext db = new Yetkilim.Web.Models.Ef.yetkilimDBContext())
                {
                    db.ChangeTracker.QueryTrackingBehavior    = QueryTrackingBehavior.NoTracking;
                    db.ChangeTracker.AutoDetectChangesEnabled = false;

                    var placesIds = new List <int?>();

                    if (base.CurrentUser.Role == UserRole.Admin)
                    {
                        var currentUserCompanyId = base.CurrentUser.CompanyId;
                        placesIds = db.Places.Where(x => x.CompanyId == currentUserCompanyId).Select(x => (int?)x.Id).ToList();
                    }
                    else if (base.CurrentUser.Role == UserRole.Dealer)
                    {
                        var currentPlaceId = base.CurrentUser.PlaceId;
                        placesIds = db.Places.Where(x => x.Id == currentPlaceId).Select(x => (int?)x.Id).ToList();
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback0.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "0");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback1.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "1");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback2.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "2");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback3.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "3");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback4.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "4");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback5.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "5");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback6.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "6");
                    }

                    {
                        table += "<br/>";
                        var temp = db.Feedback7.AsNoTracking()
                                   .WhereIf(base.CurrentUser.Role != UserRole.SuperAdmin, x => placesIds.Contains(x.PlaceId)).ToArray().OrderByDescending(x => x.CreatedDate ?? DateTime.Now).ToArray();
                        feedbackCount += temp.Length;
                        table         += myTableMaker(temp, "7");
                    }
                    //model.PlaceCount = base.CurrentUser.Role != UserRole.SuperAdmin ? placesIds.Count : db.Places.Count();
                    //model.FeedbackCount = feedbackCount;
                }

                ViewBag.Table = table;
                ((dynamic)ViewBag).CompanyName = base.CurrentUser.CompanyName;
                return(View((object)model));
            }
            catch (Exception ex)
            {
                LoggerExtensions.LogError(_logger, ex, "Panel Index Error", Array.Empty <object>());
                return(this.RedirectToAction("SignOut"));
            }
        }