public void ProcessContact(InputCardModel model) { /* if (string.IsNullOrEmpty(model.CardHolderName)) * { * throw new Exception("Property name is missing"); * }*/ }
public int AddCard(InputCardModel card, string userId) { var newCard = new Card { Name = card.Name, Description = card.Description, Health = card.Health, Attack = card.Attack, ImageUrl = card.Image, Keyword = card.Keyword, CreatorId = userId, }; db.Cards.Add(newCard); db.SaveChanges(); return(newCard.Id); }
public HttpResponse Add(InputCardModel card) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (card.Name.Length < 5 || card.Name.Length > 15) { return(this.Error("Card name should be between 5 and 15!")); } if (string.IsNullOrEmpty(card.Image)) { return(this.Error("Image is required!")); } if (string.IsNullOrEmpty(card.Keyword)) { return(this.Error("Image is required!")); } if (card.Attack < 0) { return(this.Error("Attack can not be negative!")); } if (card.Health < 0) { return(this.Error("Health can not be negative!")); } if (string.IsNullOrEmpty(card.Description) || card.Description.Length > 200) { return(this.Error("Description can not be over 200 characters!")); } var userId = this.GetUserId(); int cardId = cardService.AddCard(card, userId); cardService.AddCardToCollection(userId, cardId); return(this.Redirect("/Cards/All")); }
public async Task<IActionResult> Pay(InputCardModel model) { var user =await _userManager.GetUserAsync(User); user.CardHolderName = model.CardHolderName; user.CardNumber = model.CardNumber; user.Month = model.Month; user.Year = model.Year; user.SecurityNumber = model.SecurityNumber; await _userManager.UpdateAsync(user); if (!ModelState.IsValid) { ViewData["ErrorMessage"]= "error"; return View(model); } _contactService.ProcessContact(model); return View(model); }