Example #1
0
        public static CardTypeViewModel ConvertToView(this CardType cardType)
        {
            CardTypeViewModel cardTypeViewModel = new CardTypeViewModel
            {
                id     = Convert.ToInt16(cardType.Id),
                name   = cardType.Name,
                prefix = cardType.Prefix
            };

            return(cardTypeViewModel);
        }
        public async Task <IActionResult> Create([Bind("Id,TypeName")] CardTypeViewModel cardTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                var cardTypeDTO = _mapper.Map <CardTypeDTO>(cardTypeViewModel);
                await _genericService.AddData(cardTypeDTO);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cardTypeViewModel));
        }
        public async Task <int> Update(CardTypeViewModel model)
        {
            var pd = await db.CardTypes.AsNoTracking().FirstOrDefaultAsync(x => x.Id == model.Id);

            pd.NameType    = model.NameType.ToTrim();
            pd.Description = model.Description;
            db.CardTypes.Update(pd);
            var rs = await db.SaveChangesAsync();

            return(rs); // 1 thanh cong, 0 that bai
        }
        public IActionResult Put([FromBody] CardTypeViewModel cardtypeViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(cardtypeViewModel));
            }

            _cardtypeAppService.Update(cardtypeViewModel);

            return(Response(cardtypeViewModel));
        }
        public IEnumerable <CardTypeViewModel> GetAll()
        {
            List <CardTypeViewModel> CardType = new List <CardTypeViewModel>();

            foreach (var item in db.CardTypes)
            {
                CardTypeViewModel obj = new CardTypeViewModel();
                obj.IdCardType   = item.IdCardType;
                obj.IdCardTypeId = item.IdCardTypeId;
                CardType.Add(obj);
            }
            return(CardType);
        }
        public async Task <int> Insert(CardTypeViewModel model)
        {
            model.Id          = Guid.NewGuid().ToString();
            model.NameType    = model.NameType;
            model.Description = model.Description.ToTrim();
            var entity = mp.Map <CardType>(model);
            await db.CardTypes.AddAsync(entity);

            var rs = await db.SaveChangesAsync();

            // thanh cong 1, o loi
            return(rs);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,TypeName")] CardTypeViewModel cardTypeViewModel)
        {
            if (id != cardTypeViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var cardType = _mapper.Map <CardTypeDTO>(cardTypeViewModel);
                await _genericService.UpdateData(cardType);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(cardTypeViewModel));
        }
Example #8
0
        public IActionResult AddCardAction(CardTypeViewModel c, IFormCollection form)
        {
            ViewBag.UserId = HttpContext.Session.GetString("Id");
            AddMagicCardViewModels model = new AddMagicCardViewModels();

            if (c.cardType == "MTG")
            {
                var Cards = _repo.GetMagicCards(-1);
                model.MagicCards = Cards.ToList();
                return(View("CreateMagicCard", model));
            }
            else
            {
                var Cards = _repo.GetBaseballCards(-1);
                return(View("CreateBaseballCard", model));
            }
        }
        public CardType MapToModel(CardTypeViewModel cardTypeView)
        {
            CardType cardType = new CardType();

            cardType.Id                 = cardTypeView._id;
            cardType.Uid                = cardTypeView.UId;
            cardType._IsDeleted         = cardTypeView._deleted;
            cardType.Active             = cardTypeView._active;
            cardType._CreatedUtc        = cardTypeView._createdDate;
            cardType._CreatedBy         = cardTypeView._createdBy;
            cardType._CreatedAgent      = cardTypeView._createAgent;
            cardType._LastModifiedUtc   = cardTypeView._updatedDate;
            cardType._LastModifiedBy    = cardTypeView._updatedBy;
            cardType._LastModifiedAgent = cardTypeView._updateAgent;
            cardType.Code               = cardTypeView.code;
            cardType.Description        = cardTypeView.description;
            cardType.Name               = cardTypeView.name;

            return(cardType);
        }
        public async Task <IActionResult> Update(CardTypeViewModel model)
        {
            var result = await _ICardTypeRespositories.Update(model);

            return(Ok(result));
        }
 public bool uplood(CardTypeViewModel CardType)
 {
     throw new NotImplementedException();
 }
        public void Update(CardTypeViewModel CardTypeViewModel)
        {
            var updateCommand = _mapper.Map <UpdateCardTypeCommand>(CardTypeViewModel);

            Bus.SendCommand(updateCommand);
        }
        public void Register(CardTypeViewModel CardTypeViewModel)
        {
            var registerCommand = _mapper.Map <RegisterNewCardTypeCommand>(CardTypeViewModel);

            Bus.SendCommand(registerCommand);
        }
        public JsonResult AllCard(CardTypeViewModel card)
        {
            IEnumerable <CardTypeViewModel> Cardtype = Card.GetAll();

            return(Json(Cardtype.ToList(), JsonRequestBehavior.AllowGet));
        }