Beispiel #1
0
        public ActionResult CreateOrEdit(GenreViewMdoel model)
        {
            if (ModelState.IsValid)
            {
                Artist entity = new Artist
                {
                    ID          = model.ID,
                    Name        = model.Name,
                    Description = model.Description
                };

                if (model.ID != Guid.Empty)
                {
                    _Service.Edit(entity);
                    ViewBag.Messages = "修改成功";
                }
                else
                {
                    entity.ID = Guid.NewGuid();
                    _Service.AddAndSave(entity);
                    ViewBag.Messages = "新增成功";
                }
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public JsonResult GetGenreList()
        {
            var entityList = _Service.GetRelevance <Genre>().ToList();
            var vmList     = new List <GenreViewMdoel>();

            foreach (var item in entityList)
            {
                var boVm = new GenreViewMdoel(item);
                vmList.Add(boVm);
            }
            return(Json(vmList));
        }
        public ActionResult CreateOrEdit(string id = null)
        {
            bool isNew = false;
            Guid Id;
            var  vm = new GenreViewMdoel();

            if (!String.IsNullOrEmpty(id))
            {
                isNew = true;
                Id    = Guid.Parse(id);
                var entity = _Service.GetSingleById(Id);
                vm = new GenreViewMdoel(entity);
                ViewBag.Operation = "修改";
            }
            else
            {
                ViewBag.Operation = "新建";
                ViewBag.isNew     = isNew;
            }
            return(View(vm));
        }