public void GetTotalPaidSum() { var p4 = new Publication { PublicationId = 4, NameOfPublication = "БудМайстер", Description = @"ЖУРНАЛ БУДМАЙСТЕР - специализированный журнал, который рассчитан на читателей, практикующих в области строительства, ремонта, дизайна и архитектуры. Журнал позиционируется как рекламно-информационное периодическое издание. Материалы, публикуемые в журнале, информируют о состоянии отечественного строительного рынка, перспективах развития строительного комплекса Украины, современных строительных материалах и технологиях.", Periodicity = "ежемесячно", Format = "А4", Color = "полноцвет", Volume = 100, PricePerMonth = 65, }; var p2 = new Publication { PublicationId = 2, NameOfPublication = "Auto Bild Все ведущие. Всеукраинские издания", Description = @"Журнал Auto Bild Все ведущие – это оперативные тесты авто, новости от производителей, история автомобилестроения, эксплуатация, ремонт и практические советы автомобилистам, авто-мото спорт, цены на новые авто. ", Periodicity = "ежемесячно", Format = "А4", Color = "полноцвет", Volume = 76, PricePerMonth = 60, }; Mock <IRepositoryFactory> mock = new Mock <IRepositoryFactory>(); mock.Setup(a => a.UserPublicationRepository.Get()).Returns(new List <UserPublication> { new UserPublication { UserPublicationId = 1, Publication = p4, UserId = "1", StartDate = DateTime.Now, EndDate = DateTime.Now.AddMonths(4), Period = 4, PaymentState = false }, new UserPublication { UserPublicationId = 1, Publication = p2, UserId = "1", StartDate = DateTime.Now, EndDate = DateTime.Now.AddMonths(4), Period = 1, PaymentState = true }, }); double result = UserPublicationService.GetTotalPaidSum(mock.Object); Assert.AreEqual(60, result); }
public ActionResult CreateSubscription(string name, int id) { try { UserPublicationService.CreateSubscription(_factory, name, id, User.Identity.GetUserId(), logger); return(PartialView("Subscription")); } catch (Exception ex) { logger.Error(ex, ex.Message); return(View("Error", new HandleErrorInfo(ex, "UserPublications", "CreateSubscription"))); } }
public ActionResult PublicationsOfUser(string userId) { try { var idUser = userId; var userPublicationsConcrete = UserPublicationService.GetPaidPublicationsForUser(_factory, idUser); //ViewBag.SumNotPayed = UserPublicationService.GetUnpaidSumForUser(_factory, idUser); ViewBag.SumPayed = UserPublicationService.GetPaidSumForUser(_factory, idUser); return(View("Index1", userPublicationsConcrete)); } catch (Exception ex) { logger.Error(ex, ex.Message); return(View("Error", new HandleErrorInfo(ex, "UserPublications", "PublicationsOfUser"))); } }
public ActionResult IndexByName() { try { DateTime date1 = new DateTime(2010, 1, 31, 0, 0, 0); var defaultvalue = _factory.PublicationRepository.Get().FirstOrDefault().PublicationId; var userPublications = UserPublicationService.UserPublicationsWithName(_factory, defaultvalue, date1); ViewBag.SumPayed = UserPublicationService.GetTotalPaidSumForPublication(_factory, defaultvalue, date1); ViewBag.AllPublications = _factory.PublicationRepository.Get().OrderBy(o => o.NameOfPublication); return(View(userPublications)); } catch (Exception ex) { logger.Error(ex, ex.Message); return(View("Error", new HandleErrorInfo(ex, "UserPublications", "Index1"))); } }
public ActionResult Index() { try { var idUser = User.Identity.GetUserId(); var userPublicationsConcrete = UserPublicationService.GetUserPublicationsForConcreteUser(_factory, idUser); ViewBag.Sum = UserPublicationService.GetUnpaidSumForUser(_factory, idUser); var account = UserService.GetAccountOfUser(_factory, idUser); ViewBag.AccountSum = account.Balance; return(View(userPublicationsConcrete)); } catch (Exception ex) { logger.Error(ex, ex.Message); return(View("Error", new HandleErrorInfo(ex, "UserPublications", "Index"))); } }
public ActionResult UserPublicationsSearch(int name, string month, string year) { try { int m = int.Parse(month); int y = int.Parse(year); int day = 1; switch (m) { case 1: day = 31; break; case 2: { if (y == 2016 || y == 2012) { day = 28; } else { day = 28; } break; } case 3: day = 31; break; case 4: day = 30; break; case 5: day = 31; break; case 6: day = 30; break; case 7: day = 31; break; case 8: day = 31; break; case 9: day = 30; break; case 10: day = 31; break; case 11: day = 30; break; case 12: day = 31; break; default: Console.WriteLine("Default case"); break; } DateTime date1 = new DateTime(y, m, day, 0, 0, 0); var userPublications = UserPublicationService.UserPublicationsWithName(_factory, name, date1); ViewBag.SumPayed = UserPublicationService.GetTotalPaidSumForPublication(_factory, name, date1); if (userPublications.Count <= 0) { return(PartialView("SearchUserPError")); } return(PartialView("AfterSearch", userPublications)); } catch (Exception ex) { logger.Error(ex, ex.Message); return(View("Error", new HandleErrorInfo(ex, "Publications", "PublicationSearch"))); } }