Beispiel #1
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (selectedItem == null)
            {
                selectedItem = FieldTypesMapper.CreateObject();
            }
            else
            {
                selectedItem = BaseMapper.GetObjectFromContext <FieldType>(selectedItem);
            }

            UpdateObjectFromFields();

            Return returnObj;

            if (selectedItem.ID == 0)
            {
                returnObj = FieldTypesMapper.Insert(selectedItem);
            }
            else
            {
                returnObj = FieldTypesMapper.Update(selectedItem);
            }

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error Saving Item", returnObj.Error);
            }
            else
            {
                UpdateFieldsFromObject();
                DisplaySuccessMessage("Successfully Saved Item");
            }
        }
    public bool Run(NgTableParams model, ref IQueryable <FieldType> repository, NgTable <FieldTypes> result, ICoreUser user, IUnitOfWork db)
    {
        var ngTransformer = new QueryToNgTable <FieldTypesViewModel>();

        var query = FieldTypesMapper.MapDbModelQueryToViewModelQuery(repository);

        ngTransformer.ToNgTableDataSet(model, query, result);
        return(true);
    }
    public bool Run(FieldTypesViewModel model, IUnitOfWork unitOfWork, Response <FieldTypesViewModel> result)
    {
        var newCustom = FieldTypesMapper.MapInsertModelToDbModel(model);

        unitOfWork.With <FieldType>().Add(newCustom);
        unitOfWork.SaveChanges();
        CreatedId = newCustom.Id;
        var newCustomResult = FieldTypesMapper.MapDbModelToViewModel(newCustom);

        result.Data = newCustomResult;
        return(true);
    }
Beispiel #4
0
    public bool Run(FieldTypeViewModel model, IUnitOfWork unitOfWork, Response <FieldTypeViewModel> result)
    {
        var dbModel        = unitOfWork.With <FieldType>().Find(model.Id);
        var updatedDbModel = FieldTypesMapper.MapInsertModelToDbModel(model, dbModel);

        unitOfWork.With <FieldType>().AddOrUpdate(updatedDbModel);
        unitOfWork.SaveChanges();
        var newCustomResult = FieldTypesMapper.MapDbModelToViewModel(updatedDbModel);

        result.Data = newCustomResult;
        return(true);
    }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            long id;

            if (long.TryParse(Request["id"], out id))
            {
                selectedItem = FieldTypesMapper.GetByID(id);

                if (!IsPostBack)
                {
                    UpdateFieldsFromObject();
                }
            }

            this.Page.Title = this.SectionTitle.Text = GetSectionTitle();
        }
    public Response <FieldTypesViewModel> Run(FieldTypesViewModel model, IUnitOfWork unitOfWork, Response <FieldTypesViewModel> result)
    {
        var itemToUpdate = unitOfWork.With <FieldType>().SingleOrDefault(c => c.Id == model.Id);

        if (itemToUpdate != null)
        {
            var newCustomResult = FieldTypesMapper.MapDbModelToViewModel(itemToUpdate);
            result.Data    = newCustomResult;
            result.Success = true;
        }
        else
        {
            result.Success = false;
            result.LogError("Error viewing FieldTypes");
        }

        return(result);
    }
Beispiel #7
0
        public string DeleteItemPermanently(long id)
        {
            var item = BaseMapper.GetObjectFromContext(FieldTypesMapper.GetByID(id));

            if (item != null)
            {
                Return returnObj = FieldTypesMapper.DeletePermanently(item);

                if (returnObj.IsError)
                {
                    return(jGrowlHelper.GenerateCode(new jGrowlMessage("Error", "Error deleting item permanently", jGrowlMessage.jGrowlMessageType.Error, returnObj.Error), true));
                }
                else
                {
                    return(jGrowlHelper.GenerateCode(new jGrowlMessage("Success", "Item was successfully deleted permanently", jGrowlMessage.jGrowlMessageType.Success), false));
                }
            }

            return("");
        }
 public BaseFieldsEditor()
 {
     FieldTypes = FieldTypesMapper.GetAll().ToList();
 }
 protected void Page_Init(object sender, EventArgs e)
 {
     FieldTypes = FieldTypesMapper.GetAll().ToList();
     BindFieldTypeDropDown();
 }