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)); }
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)); }
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); }
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."); }
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"); } }
private SKPaint GetTextShadowPaint(BadgeModel badge) { var paint = this.GetTextPaint(badge); paint.Color = new SKColor(0x33, 0x33, 0x33, 0xff); return(paint); }
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)); }
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)); }
public void CopyInto(IModel apiModel) { BadgeModel model = apiModel as BadgeModel; model.Name = Name; model.Text = Text; model.Image = Image; }
public void CopyFrom(IModel apiModel) { BadgeModel model = apiModel as BadgeModel; Name = model.Name; Text = model.Text; Image = model.Image; }
public void Save(BadgeDTO badge) { using (var context = new CoffeMachineDbContext()) { BadgeModel model = badge.ToModel(); context.Badges.Add(model); context.SaveChanges(); } }
public static BadgeModel AsModel(this BadgeEntity entity) { var result = new BadgeModel { Id = entity.Id, Name = entity.Name, Price = entity.Price }; return(result); }
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); }
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")); }
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)); }
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); }
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); }
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")); }
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); }
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")); }
public async Task <bool> AddAsync(BadgeModel model, string userToken) { model.Id = await SendRequestFor <int>(API.METHOD.ADD, model, userToken); return(model.Id != -1); }
public Task <bool> UpdateAsync(BadgeModel model, string userToken) { return(SendRequestFor <bool>(API.METHOD.UPDATE, model, userToken)); }
private int GetOuterMargin(BadgeModel badge) => badge.Height / 2;
private Badge(BadgeModel model) { this.model = model; }
private int GetInnerMargin(BadgeModel badge) => badge.Height / 4;
private int GetTopBottomMargin(BadgeModel badge) => badge.Height / 5;
private int GetCornerRadius(BadgeModel badge) => badge.Height / 5;
public BadgeModel CreateBadge(BadgeModel BadgeModel) { _dbReference.Badge.Add(BadgeModel); _dbReference.SaveChanges(); return(BadgeModel); }
public IActionResult CreateBadge(BadgeModel BadgeModel) { return(Ok(_db.CreateBadge(BadgeModel))); }
public IActionResult UpdateBadge(int id, BadgeModel BadgeModel) { return(Ok(_db.UpdateBadge(id, BadgeModel))); }