public ProjectImage() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = ProjectImageStatusEnum.Show; }
public BlogComment() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = BlogCommentStatusEnum.Published; }
public Vote() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = VoteStatusEnum.UpVote; }
public Category() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = CategoryStatusEnum.Show; }
public Donation() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = DonationStatusEnum.Pending; }
public Follow() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = FollowStatusEnum.Followed; }
public Project() { Id = Guid.NewGuid().ToString(); CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); CurrentFund = 0; Status = ProjectStatusEnum.Establishing; }
public ActionResult Edit([Bind(Include = "Id,Name,Description,CreatedAt,UpdatedAt,DeletedAt,Status")] Category category) { if (!ModelState.IsValid) { return(View(category)); } category.UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); _db.Entry(category).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(string id) { var category = _db.Categories.Find(id); if (category == null) { return(HttpNotFound()); } category.Status = Category.CategoryStatusEnum.Deleted; category.DeletedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); _db.Entry(category).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditStatus(EditStatusDonationViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var res = _db.Donations.Find(model.Id); if (res == null) { return(HttpNotFound()); } res.Status = model.Status; res.UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); _db.Entry(res).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index", "Dashboard")); }
public ApplicationUserRole() { CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); }
public ApplicationUser() { CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow); Status = UserStatusEnum.Activated; }
// GET: Donations public async Task <ActionResult> Index(int?page, int?limit, string start, string end, string nameProject, double?minAmount, double?maxAmount, int?status, int?method, int?sortBy, int?direct, int?advance, int?view) { if (view == null || view > 1 || view < 0) { view = 0; } if (advance == null || advance > 1 || advance < 0) { advance = 0; } if (minAmount == null) { minAmount = 0; } if (maxAmount == null) { maxAmount = 100; } if (nameProject.IsNullOrWhiteSpace()) { nameProject = ""; } Debug.WriteLine(start + " " + end); if (string.IsNullOrWhiteSpace(start) && !HelperMethod.CheckValidDate(start)) { start = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow).AddYears(-1).ToString("yyyy-MM-dd"); } var startDate = DateTime.ParseExact(start, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (string.IsNullOrWhiteSpace(end) && !HelperMethod.CheckValidDate(end)) { end = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow).ToString("yyyy-MM-dd"); } var endDate = DateTime.ParseExact(end, "yyyy-MM-dd", CultureInfo.InvariantCulture); var donations = await _db.Donations.Where(d => d.CreatedAt >= startDate && d.CreatedAt <= endDate && d.Project.Name.Contains(nameProject)).ToListAsync(); donations = donations.Where(p => p.Amount <= maxAmount && p.Amount >= minAmount).ToList(); if (status != null && Enum.IsDefined(typeof(Donation.DonationStatusEnum), status)) { donations = donations.Where(d => d.Status == (Donation.DonationStatusEnum)status).ToList(); } else { status = 20; } if (method != null && Enum.IsDefined(typeof(Donation.PaymentMethodEnum), method)) { donations = donations.Where(d => d.PaymentMethod == (Donation.PaymentMethodEnum)method).ToList(); } else { method = 20; } if (sortBy == null || !Enum.IsDefined(typeof(HelperEnum.DonationSortEnum), sortBy)) { Debug.WriteLine(sortBy); sortBy = 0; } if (direct == null || !Enum.IsDefined(typeof(HelperEnum.DonationDirectEnum), direct)) { Debug.WriteLine(direct); direct = 0; } //sorting var listDonation = new List <Donation>(); switch (sortBy) { case (int)HelperEnum.DonationSortEnum.CreatedAt when direct is (int)HelperEnum.DonationDirectEnum.Asc: { var dataList = donations.OrderBy(p => p.CreatedAt).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.CreatedAt: { var dataList = donations.OrderByDescending(p => p.CreatedAt).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.UserName when direct is (int)HelperEnum.DonationDirectEnum.Asc: { var dataList = donations.OrderBy(d => d.ApplicationUser.UserName).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.UserName: { var dataList = donations.OrderByDescending (d => d.ApplicationUser.UserName).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.Amount when direct is (int)HelperEnum.DonationDirectEnum.Asc: { var dataList = donations.OrderBy(p => p.Amount).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.Amount: { var dataList = donations.OrderByDescending(p => p.Amount).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.PaymentMethod when direct is (int)HelperEnum.DonationDirectEnum.Asc: { var dataList = donations.OrderBy(p => p.PaymentMethod).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.PaymentMethod: { var dataList = donations.OrderByDescending(p => p.PaymentMethod).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.Status when direct is (int)HelperEnum.DonationDirectEnum.Asc: { var dataList = donations.OrderBy(p => p.Status).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.Status: { var dataList = donations.OrderByDescending(p => p.Status).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.ProjectName when direct is (int)HelperEnum.DonationDirectEnum.Asc: { var dataList = donations.OrderBy(p => p.Project.Name).ToList(); listDonation.AddRange(dataList); break; } case (int)HelperEnum.DonationSortEnum.ProjectName: { var dataList = donations.OrderByDescending(p => p.Project.Name).ToList(); listDonation.AddRange(dataList); break; } default: { var dataList = donations.OrderBy(p => p.CreatedAt).ToList(); listDonation.AddRange(dataList); break; } } Debug.WriteLine(startDate + " " + endDate); ViewBag.view = view; ViewBag.advance = advance; ViewBag.Start = start; ViewBag.End = end; ViewBag.CurrentPage = page ?? 1; ViewBag.TotalItem = listDonation.Count; ViewBag.Limit = limit ?? 10; ViewBag.TotalPage = Math.Ceiling((double)listDonation.Count / (limit ?? 10)); ViewBag.nameProject = nameProject; ViewBag.minAmount = minAmount; ViewBag.maxAmount = maxAmount; ViewBag.status = status; ViewBag.method = method; ViewBag.sortBy = sortBy; ViewBag.direct = direct; ViewBag.directSet = direct is (int)HelperEnum.DonationDirectEnum.Asc ? (int)HelperEnum.DonationDirectEnum.Desc : (int)HelperEnum.DonationDirectEnum.Asc; listDonation = listDonation.Skip(((page ?? 1) - 1) * (limit ?? 10)).Take((limit ?? 10)).ToList(); var data = listDonation.Select(item => new DonationListViewModel { Status = item.Status, CreatedAt = item.CreatedAt, Amount = item.Amount, ProjectId = item.ProjectId, UserName = item.ApplicationUser.UserName, PaymentMethod = item.PaymentMethod, Avatar = item.ApplicationUser.Avatar, UserId = item.ApplicationUserId, Id = item.Id, ProjectName = item.Project.Name }) .ToList(); return(View(data)); }