예제 #1
0
        public ViewResult Edit(string id)
        {
            MemeModel meme = null;

            Guid memeGuid;
            if (Guid.TryParse(id, out memeGuid))
            {
                meme = _memeRepository.Get(memeGuid).ToModel();
            }
            else
            {
                meme = new MemeModel { MemeID = Guid.Empty };
            }

            return View(meme);
        }
예제 #2
0
        public ActionResult Edit(MemeModel memeModel, string action)
        {
            switch (action)
            {
                case "save":
                    {
                        if (ModelState.IsValid)
                        {
                            if (memeModel.MemeID == Guid.Empty)
                            {
                                memeModel.MemeID = Guid.NewGuid();
                                _memeRepository.Add(memeModel.FromModel());
                            }
                            else
                            {
                                _memeRepository.Update(memeModel.FromModel());
                            }
                        }
                        else
                        {
                            return View(memeModel);
                        }

                        break;
                    }
                case "delete":
                    {
                        if (memeModel != null)
                        {
                            _memeRepository.Delete(memeModel.MemeID);
                        }

                        break;
                    }
                default:
                    break;
            }

            return RedirectToAction("Edit", new { id = Guid.Empty });
        }
예제 #3
0
 public void Add(MemeModel meme)
 {
     Memes.Add(meme);
 }