public void ConstructorShouldCreate_DomainDetailsViewModel_WithoutParams() { // Act & Assert var domainDetailsViewModel = new DomainDetailsViewModel(); Assert.IsInstanceOf <DomainDetailsViewModel>(domainDetailsViewModel); }
public ActionResult BuyDomain(DomainDetailsViewModel domainDetails) { var buyerId = this.loggedInUser.GetUserId(); var domainId = domainDetails.Id; var sellerId = domainDetails.SellerId; var buyerAlreadyOwnsDomain = this.domainService.CheckIfBuyerOwnsCertainDomain(domainId, buyerId); if (buyerAlreadyOwnsDomain) { TempData["Error"] = "You already own " + domainDetails.Name; return(RedirectToAction("Details", "Domain", new { area = "", id = domainDetails.Id })); } var amount = (decimal)domainDetails.Price; var buyerHasEnoughMoney = this.userService.CheckIfBuyerHasEnoughMoney(buyerId, amount); if (!buyerHasEnoughMoney) { TempData["Error"] = "Not enough funds! You can top up your account from the Dashboard"; return(RedirectToAction("Details", "Domain", new { area = "", id = domainDetails.Id })); } this.userService.BuyDomain(buyerId, domainId); this.domainService.UpdateDomainToBought(domainId); this.userService.TransferAmountFromBuyerToSeller(buyerId, amount, sellerId); TempData["Success"] = "Horay! You bought " + domainDetails.Name + "!"; return(RedirectToAction("Index")); }
public static void CreateDomain() { if (_domain == null) { _domain = new DomainDetailsViewModel(); } }
public ActionResult Details(int?id) { if (id == null || id < 1) { return(RedirectToAction("Index", "Home")); } int domainId = (int)id; var domain = this.domainService.GetDomainById(domainId); if (domain == null) { return(RedirectToAction("Index", "Home")); } var domainViewModel = new DomainDetailsViewModel() { Id = domain.Id, Name = domain.Name, Description = domain.Description, SellerName = domain.User.FirstName + " " + domain.User.LastName, DesignerName = domain.Designer.FirstName + " " + domain.Designer.LastName, Price = domain.OriginalOwnerCustomPrice, LogoUrl = domain.LogoUrl, SellerId = domain.UserId, PostedOn = (DateTime)domain.UpdatedAt }; return(View(domainViewModel)); }
public void DomainViewModel_Should_Set_Properties_Correctly_With_CorrectData() { // Arrange int id = 1; string name = "name"; string logoUrl = "logoUrl"; decimal?price = 1m; var domainViewModel = new DomainDetailsViewModel() { Id = id, Name = name, LogoUrl = logoUrl, Price = price }; // Act & Assert Assert.AreEqual(id, domainViewModel.Id); Assert.AreEqual(name, domainViewModel.Name); Assert.AreEqual(logoUrl, domainViewModel.LogoUrl); Assert.AreEqual(price, domainViewModel.Price); }
public void DomainDetailsViewModel_Should_Set_Properties_Correctly_With_CorrectData() { // Arrange int id = 1; string name = "name"; string description = "description"; string sellerName = "seller name"; string designerName = "designer name"; string sellerId = "sellerId"; DateTime postedOn = new DateTime(17, 01, 01); string logoUrl = "logoUrl"; decimal? price = 1m; var domainDetailsViewModel = new DomainDetailsViewModel() { Id = id, Name = name, LogoUrl = logoUrl, Price = price, Description = description, SellerName = sellerName, DesignerName = designerName, SellerId = sellerId, PostedOn = postedOn }; // Act & Assert Assert.AreEqual(id, domainDetailsViewModel.Id); Assert.AreEqual(name, domainDetailsViewModel.Name); Assert.AreEqual(logoUrl, domainDetailsViewModel.LogoUrl); Assert.AreEqual(price, domainDetailsViewModel.Price); Assert.AreEqual(description, domainDetailsViewModel.Description); Assert.AreEqual(sellerName, domainDetailsViewModel.SellerName); Assert.AreEqual(designerName, domainDetailsViewModel.DesignerName); Assert.AreEqual(sellerId, domainDetailsViewModel.SellerId); Assert.AreEqual(postedOn, domainDetailsViewModel.PostedOn); }
public static void ClearDomain() { _domain.Cleanup(); _domain = null; }