Example #1
0
 public ActionResult Create(MapModel model)
 {
     if (ModelState.IsValid)
     {
         if (mapService.AlreadyExists(model.Name, Guid.Empty))
         {
             ModelState.AddModelError("Name", "名称重复");
         }
         else if (model.ImageIds.Count != 1)
         {
             ModelState.AddModelError("ImageIds", "只能选择一张图片");
         }
         else
         {
             var entity = model.ToEntity();
             mapService.Add(entity);
             MediaHelper.SaveHasMedias(entity.Id, model.ImageIds);
             return(Json(new AjaxResult()
             {
                 Result = Result.Success
             }));
         }
     }
     return(View(PluginHelper.GetViewPath(this.GetType(), "Create"), model));
 }