public HttpResponse Add(AddCardModel input) { if (input.Name.Length < 5 || input.Name.Length > 15) { return(this.Error("Name should be between 5 and 15 characters long")); } if (input.Attack < 0) { return(this.Error("Attack should be positive number")); } if (input.Health < 0) { return(this.Error("Health should be positive number")); } if (input.Description.Length > 200) { return(this.Error("Description should be less than 200 characters long")); } int cardId = this.CardsService.AddCard(input); var user = this.GetUserId(); this.CardsService.AddCardToUserCollection(user, cardId); return(this.Redirect("/Cards/All")); }
public HttpResponseMessage addCart(AddCardModel model) { //string result = ""; ApiResponseData response = new ApiResponseData(); Business business = new Business(); IntMessage im = new IntMessage(); try { //MemberViewModel model = (MemberViewModel)JsonConvert.DeserializeObject(value, typeof(MemberViewModel)); im = business.addCart(model.tempOrderID, model.productCustomizeID , model.productName, model.quantity, model.price, model.unitName); response.Result = im.Result.ToString(); //if (im.Result >0) //{ // response.Result = im.Result; //} } catch (Exception ex) { business.addErrorLog("WebApi", "addCart", ex.Message); //Utility.ErrorMessageToLogFile(ex); //throw; } string result = JsonConvert.SerializeObject(response); return(new HttpResponseMessage() { Content = new StringContent(result) }); }
public int AddCard(AddCardModel model) { Card card = new Card() { Name = model.Name, ImageUrl = model.Image, Attack = model.Attack, Health = model.Health, Description = model.Description, Keyword = model.Keyword, }; this.Db.Cards.Add(card); this.Db.SaveChanges(); return(card.Id); }