Beispiel #1
0
        public ActionResult EditExternalMethod(Guid?id, Guid?FormId, MetaFormExternalMethodModel model, string button)
        {
            if (string.IsNullOrEmpty(button))
            {
                return(View(model));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (DBEntities context = Settings.CreateDataContext())
            {
                MetaFormExternalMethod target = null;
                if (model.Id != Guid.Empty)
                {
                    target = MetaFormHelper.GetExternalMethod(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    target    = new MetaFormExternalMethod();
                    target.Id = model.Id = Guid.NewGuid();
                    context.AddToMetaFormExternalMethod(target);
                }

                MetaFormExternalMethodModel.CreateMap();
                target = Mapper.Map(model, target);

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", Resources.Resource.SaveError + ": " + ex.Message);
                }
            }

            if (button == "SaveAndExit")
            {
                return(RedirectToAction("Edit", new { id = model.MetaFormId }));
            }
            else
            {
                return(RedirectToAction("EditExternalMethod", new { id = model.Id }));
            }
        }
Beispiel #2
0
        public ActionResult EditExternalMethod(Guid?id, Guid?FormId)
        {
            MetaFormExternalMethodModel model = null;

            if (id.HasValue)
            {
                var att = MetaFormHelper.GetExternalMethod(id.Value);
                if (att == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                MetaFormExternalMethodModel.CreateMap();
                model = Mapper.Map <MetaFormExternalMethod, MetaFormExternalMethodModel>(att);
                return(View(model));
            }
            else if (FormId.HasValue)
            {
                MetaForm item = MetaFormHelper.Get(FormId.Value);
                if (item != null)
                {
                    return(View(new MetaFormExternalMethodModel
                    {
                        MetaFormId = item.Id,
                        MetaFormCaption = item.Caption,
                    }));
                }
                else
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }
            }
            else
            {
                return(MessageHelper.FormedContentObjectNotFound());
            }
        }