public ActionResult Edit(EditProjectSourceTypeModel model)
        {
            if (!ModelState.IsValid)
            {
                return Redirect(Url.ProjectSourceType_Edit(model.Id));
            }
            ProjectSourceTypeObj obj;
            if (!model.Id.HasValue)
            {
                obj = ModelConverter.Convert(model);
                obj.Id = ProjectSourceTypeLogic.Create(obj, CurrentUserName);
                if (obj.Id == -1)
                {
                    this.AddError("CreatingProjectSourceType", "There was an error creating your ProjectSourceType. If this continues contact support.");
                    return Redirect(Url.ProjectSourceType_Create());
                }
            }
            else
            {
                obj = ModelConverter.Convert(model);
                var success = ProjectSourceTypeLogic.Update(obj, CurrentUserName);
                if (!success)
                {
                    this.AddError("UpdatingProjectSourceType", "There was an error updating your ProjectSourceType. If this continues contact support.");
                    return Redirect(Url.ProjectSourceType_Edit(model.Id.Value));
                }
            }

            return Redirect(Url.ProjectSourceType_Show(obj.Id.Value));
        }
        public ActionResult Edit(int? id = null)
        {
            EditProjectSourceTypeModel model = null;
            if (id.HasValue)
            {
                var obj = ProjectSourceTypeLogic.Get(id.Value);
                if (obj != null)
                {
                    model = ModelConverter.ConvertToEdit(obj);
                }
                else
                {
                    this.AddWarning("NoProjectSourceTypeFound", "No ProjectSourceType was found with that Id. Switching to Create mode.");
                    return Redirect(Url.ProjectSourceType_Create());
                }
            }

            if (model == null)
            {
                model = new EditProjectSourceTypeModel();
            }
            return View("Edit", model);
        }
Exemplo n.º 3
0
 internal static ProjectSourceTypeObj Convert(EditProjectSourceTypeModel model)
 {
     return new ProjectSourceTypeObj
     {
         Id = model.Id,
         Name = model.Name,
         FullClassName = model.FullClassName,
         Interval = model.Interval,
         NextRun = model.ForceRun ? DateTime.MinValue : (DateTime?)null,
         Enabled = model.Enabled
     };
 }