コード例 #1
0
        public ActionResult SenderCompleteTasksCount()
        {
            int count = 0;

            try
            {
                using (var context = new TaskManagerContext())
                {
                    count = context.Tasks.Count(x => x.SenderId == WebSecurity.CurrentUserId && x.CompleteDate.HasValue && !x.AcceptCpmpleteDate.HasValue);
                }
            }
            catch (Exception)
            {
            }
            var badge = new BadgeModel {
                Count = count
            };

            if (Session["SenderCompleteTasksCount"] != null && ((int)Session["SenderCompleteTasksCount"]) < count)
            {
                badge.IsPlay = true;
            }
            Session["SenderCompleteTasksCount"] = count;

            return(PartialView(badge));
        }
コード例 #2
0
        public ActionResult OverdueTasksCount()
        {
            int count;

            try
            {
                using (var context = new TaskManagerContext())
                {
                    count = context.Tasks.Where(x => x.Deadline.HasValue).ToList().Count(y => y.Deadline.Value.Date < DateTime.Now.Date);
                }
            }
            catch (Exception)
            {
                throw;
            }
            var res = new BadgeModel {
                Count = count
            };

            if (Session["NewTasksForManage"] != null && ((int)Session["NewTasksForManage"]) < count)
            {
                res.IsPlay = true;
            }
            Session["OverdueTasksForManage"] = count;
            return(PartialView(res));
        }
コード例 #3
0
ファイル: SqlBadge.cs プロジェクト: shimanto7710/review-apis
        public BadgeModel UpdateBadge(int id, BadgeModel BadgeModel)
        {
            var badge = _dbReference.Badge.Find(id);

            if (badge != null)
            {
                if (BadgeModel.Name != null)
                {
                    badge.Name = BadgeModel.Name;
                }

                if (BadgeModel.CreatedAt != null)
                {
                    badge.CreatedAt = BadgeModel.CreatedAt;
                }

                if (BadgeModel.Point != 0)
                {
                    badge.Point = BadgeModel.Point;
                }

                _dbReference.Update(badge);
                _dbReference.SaveChangesAsync();
                return(badge);
            }

            return(BadgeModel);
        }
コード例 #4
0
        public void GetBadgeTest()
        {
            // Arrange
            const string badgeName = "Organizer";
            var          badge     = new BadgeModel()
            {
                Name        = badgeName,
                Description = "Add your first expense",
                BadgeImgUri = "picture"
            };
            Guid badgeId;

            using (var dbContext = new ExpenseDbContext(Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                dbContext.Badges.Add(badge);
                dbContext.SaveChanges();
                badgeId = badge.Id;
            }

            // Act
            var myBadge = _balanceFacade.GetBadge(badgeId);

            // Assert
            Assert.That(myBadge.Name == badgeName, "Badge was not got.");
        }
コード例 #5
0
        public void TryGetModelByGUIDWorks()
        {
            var graphModel          = m_GraphAsset.GraphModel;
            var node1               = graphModel.CreateNode <Type0FakeNodeModel>();
            var node2               = graphModel.CreateNode <Type0FakeNodeModel>();
            var edge                = graphModel.CreateEdge(node1.ExeInput0, node2.ExeOutput0);
            var placemat            = graphModel.CreatePlacemat(new Rect(100, 100, 300, 300));
            var stickyNote          = graphModel.CreateStickyNote(new Rect(-100, -100, 100, 100));
            var constant            = graphModel.CreateConstantNode(TypeHandle.Float, "constant", new Vector2(42, 42));
            var variableDeclaration = graphModel.CreateGraphVariableDeclaration(TypeHandle.Float, "varDecl", ModifierFlags.None, true);
            var variable            = graphModel.CreateVariableNode(variableDeclaration, new Vector2(-76, 245));
            var portal              = graphModel.CreateEntryPortalFromEdge(edge);
            var badge               = new BadgeModel(node1);

            graphModel.AddBadge(badge);

            var graphElements = new IGraphElementModel[] { node1, node2, edge, placemat, stickyNote, constant, variableDeclaration, variable, portal, badge };

            foreach (var element in graphElements)
            {
                Assert.IsTrue(graphModel.TryGetModelFromGuid(element.Guid, out var retrieved), element + " was not found");
                Assert.AreSame(element, retrieved);
            }

            graphModel.DeleteBadges();
            graphModel.DeleteEdges(new[] { edge });
            graphModel.DeleteNodes(new IInputOutputPortsNodeModel[] { node1, node2, constant, variable, portal }, true);
            graphModel.DeletePlacemats(new[] { placemat });
            graphModel.DeleteStickyNotes(new[] { stickyNote });
            graphModel.DeleteVariableDeclarations(new[] { variableDeclaration });
            foreach (var element in graphElements)
            {
                Assert.IsFalse(graphModel.TryGetModelFromGuid(element.Guid, out _), element + " was found after removal");
            }
        }
コード例 #6
0
ファイル: BadgeService.cs プロジェクト: 8/badger
        private SKPaint GetTextShadowPaint(BadgeModel badge)
        {
            var paint = this.GetTextPaint(badge);

            paint.Color = new SKColor(0x33, 0x33, 0x33, 0xff);
            return(paint);
        }
コード例 #7
0
        public ActionResult NewTasksCount()
        {
            int count;

            try
            {
                using (var context = new TaskManagerContext())
                {
                    count = context.Tasks.Count(x => x.TaskRecipient == null);
                }
            }
            catch (Exception)
            {
                throw;
            }
            var res = new BadgeModel {
                Count = count
            };

            if (Session["NewTasksForManage"] != null && ((int)Session["NewTasksForManage"]) < count)
            {
                res.IsPlay = true;
            }
            Session["NewTasksForManage"] = count;
            return(PartialView(res));
        }
コード例 #8
0
        public ActionResult RecipNewTasksCount()
        {
            int count = 0;

            try
            {
                using (var context = new TaskManagerContext())
                {
                    count = context.Tasks.Count(x => x.RecipientId == WebSecurity.CurrentUserId && x.IsRecipientViewed == false);
                }
            }
            catch (Exception)
            {
            }
            var badge = new BadgeModel {
                Count = count
            };

            if (Session["RecipNewTasksCount"] != null && ((int)Session["RecipNewTasksCount"]) < count)
            {
                badge.IsPlay = true;
            }
            Session["RecipNewTasksCount"] = count;

            return(PartialView(badge));
        }
コード例 #9
0
        public void CopyInto(IModel apiModel)
        {
            BadgeModel model = apiModel as BadgeModel;

            model.Name  = Name;
            model.Text  = Text;
            model.Image = Image;
        }
コード例 #10
0
        public void CopyFrom(IModel apiModel)
        {
            BadgeModel model = apiModel as BadgeModel;

            Name  = model.Name;
            Text  = model.Text;
            Image = model.Image;
        }
コード例 #11
0
        public void Save(BadgeDTO badge)
        {
            using (var context = new CoffeMachineDbContext())
            {
                BadgeModel model = badge.ToModel();

                context.Badges.Add(model);
                context.SaveChanges();
            }
        }
コード例 #12
0
        public static BadgeModel AsModel(this BadgeEntity entity)
        {
            var result = new BadgeModel
            {
                Id    = entity.Id,
                Name  = entity.Name,
                Price = entity.Price
            };

            return(result);
        }
コード例 #13
0
ファイル: Badge.cs プロジェクト: Elbunda7/ZalDomain_old
        internal static async Task <Badge> Add(string name, string text, string image)
        {
            var badgeModel = new BadgeModel {
                Name  = name,
                Text  = text,
                Image = image
            };

            if (await Gateway.AddAsync(badgeModel, Zal.Session.Token))
            {
                return(new Badge(badgeModel));
            }
            return(null);
        }
コード例 #14
0
        public IActionResult Delete(BadgeModel model)
        {
            if (Database.Projects.ToList().Any(i => i.Badges.Contains(model.Name, StringComparison.InvariantCulture)))
            {
                ModelState.Clear();
                ModelState.AddModelError("Error", "Remove badge references from projects descriptions in order to delete the badge");
                return(View(Database.Badges.Find(model?.Name)));
            }

            Database.Badges.Remove(model);
            Database.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #15
0
        public ActionResult NewUsersCount()
        {
            var count = ModelHelper.GetNewUsersCount();
            var badge = new BadgeModel {
                Count = count
            };

            if (Session["NewUsersCount"] != null && ((int)Session["NewUsersCount"]) < count)
            {
                badge.IsPlay = true;
            }
            Session["NewUsersCount"] = count;

            return(PartialView(badge));
        }
コード例 #16
0
        public UsuarioBaseModel converterUsuarioParaUsuarioModel()
        {
            var usuarioModel = new UsuarioBaseModel(this.Id, this.Nome, this.Email, this.UrlFotoPerfil, this.Endereco, this.DataCadastro, this.Descricao);

            foreach (var badge in Badges)
            {
                var badgeModel = new BadgeModel();
                badgeModel.Id        = badge.Id;
                badgeModel.Titulo    = badge.Titulo;
                badgeModel.Descricao = badge.Descricao;
                badgeModel.Tipo      = badge.Tipo;
                usuarioModel.Badges.Add(badgeModel);
            }
            return(usuarioModel);
        }
コード例 #17
0
ファイル: BadgeService.cs プロジェクト: 8/badger
        public float GetWidth(BadgeModel badge)
        {
            var paint = GetTextPaint(badge);

            int outerMargin = GetOuterMargin(badge),
                innerMargin = GetInnerMargin(badge);

            var width = outerMargin
                        + paint.MeasureText(badge.Label)
                        + innerMargin
                        + innerMargin
                        + paint.MeasureText(badge.Result)
                        + outerMargin;

            return(width);
        }
コード例 #18
0
        public IActionResult Edit(BadgeModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Error", "Invalid data");
                return(View(model));
            }

            Database.Badges.Update(model);
            Database.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #19
0
ファイル: BadgeService.cs プロジェクト: 8/badger
        public void DrawBadge(SKCanvas canvas, BadgeModel badge)
        {
            canvas.Clear();

            var   textPaint       = this.GetTextPaint(badge);
            float outerMargin     = this.GetOuterMargin(badge),
                  innerMargin     = this.GetInnerMargin(badge);
            float leftTextWidth   = textPaint.MeasureText(badge.Label);
            float leftSideWidth   = outerMargin + leftTextWidth + innerMargin;
            float topBottomMargin = this.GetTopBottomMargin(badge);
            float textY           = badge.Height / 2 + textPaint.FontMetrics.Bottom;
            float cornerRadius    = GetCornerRadius(badge);

            /* draw left background */
            var labelBackgroundPaint = this.GetLabelBackgroundPaint(badge);

            canvas.DrawRoundRect(0, 0, leftSideWidth, badge.Height, cornerRadius, cornerRadius, labelBackgroundPaint);
            canvas.DrawRect(leftSideWidth - cornerRadius, 0, cornerRadius, badge.Height, labelBackgroundPaint);

            /* draw right background */
            var resultBackgroundPaint = this.GetResultBackgroundPaint(badge);

            canvas.DrawRoundRect(leftSideWidth, 0, innerMargin + textPaint.MeasureText(badge.Result) + outerMargin, badge.Height, cornerRadius, cornerRadius, resultBackgroundPaint);
            canvas.DrawRect(leftSideWidth, 0, cornerRadius, badge.Height, resultBackgroundPaint);

            /* write left text */
            var   textShadowPaint = this.GetTextShadowPaint(badge);
            float shadowFactor    = 1.05f;

            canvas.DrawText(badge.Label, outerMargin, textY * shadowFactor, textShadowPaint);
            canvas.DrawText(badge.Label, outerMargin, textY, textPaint);

            /* write right text */
            float rightTextX = leftSideWidth + innerMargin;

            canvas.DrawText(badge.Result, x: rightTextX, y: textY * shadowFactor, paint: textShadowPaint);
            canvas.DrawText(badge.Result, x: rightTextX, y: textY, paint: textPaint);
        }
コード例 #20
0
        public IActionResult Create(BadgeModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Error", "Invalid data");
                return(View(model));
            }

            if (Database.Badges.Any(i => i.Name == model.Name))
            {
                ModelState.AddModelError("Error", $"Badge '{model.Name}' is already exists");
                return(View(model));
            }

            Database.Badges.Add(model);
            Database.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #21
0
        public async Task <bool> AddAsync(BadgeModel model, string userToken)
        {
            model.Id = await SendRequestFor <int>(API.METHOD.ADD, model, userToken);

            return(model.Id != -1);
        }
コード例 #22
0
 public Task <bool> UpdateAsync(BadgeModel model, string userToken)
 {
     return(SendRequestFor <bool>(API.METHOD.UPDATE, model, userToken));
 }
コード例 #23
0
ファイル: BadgeService.cs プロジェクト: 8/badger
 private int GetOuterMargin(BadgeModel badge) => badge.Height / 2;
コード例 #24
0
ファイル: Badge.cs プロジェクト: Elbunda7/ZalDomain_old
 private Badge(BadgeModel model)
 {
     this.model = model;
 }
コード例 #25
0
ファイル: BadgeService.cs プロジェクト: 8/badger
 private int GetInnerMargin(BadgeModel badge) => badge.Height / 4;
コード例 #26
0
ファイル: BadgeService.cs プロジェクト: 8/badger
 private int GetTopBottomMargin(BadgeModel badge) => badge.Height / 5;
コード例 #27
0
ファイル: BadgeService.cs プロジェクト: 8/badger
 private int GetCornerRadius(BadgeModel badge) => badge.Height / 5;
コード例 #28
0
ファイル: SqlBadge.cs プロジェクト: shimanto7710/review-apis
 public BadgeModel CreateBadge(BadgeModel BadgeModel)
 {
     _dbReference.Badge.Add(BadgeModel);
     _dbReference.SaveChanges();
     return(BadgeModel);
 }
コード例 #29
0
 public IActionResult CreateBadge(BadgeModel BadgeModel)
 {
     return(Ok(_db.CreateBadge(BadgeModel)));
 }
コード例 #30
0
 public IActionResult UpdateBadge(int id, BadgeModel BadgeModel)
 {
     return(Ok(_db.UpdateBadge(id, BadgeModel)));
 }