// POST odata/ElementField
        public virtual async Task<IHttpActionResult> Post(ElementField elementField)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                await MainUnitOfWork.InsertAsync(elementField);
            }
            catch (DbUpdateException)
            {
                if (MainUnitOfWork.Exists(elementField.Id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return Created(elementField);
        }
        // PUT odata/ElementField(5)
        public virtual async Task<IHttpActionResult> Put([FromODataUri] int key, ElementField elementField)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (key != elementField.Id)
            {
                return BadRequest();
            }

            try
            {
                await MainUnitOfWork.UpdateAsync(elementField);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MainUnitOfWork.Exists(key))
                {
                    return NotFound();
                }
                else
                {
                    return Conflict();
                }
            }

            return Ok(elementField);
        }
Beispiel #3
0
        public UserElementField(ElementField elementField, decimal rating)
            : this()
        {
            Validations.ArgumentNullOrDefault(elementField, "elementField");

            ElementField = elementField;
            Rating       = rating;
        }
Beispiel #4
0
        public ElementCell(ElementField field, ElementItem item)
            : this()
        {
            Validations.ArgumentNullOrDefault(field, "field");
            Validations.ArgumentNullOrDefault(item, "item");

            ElementField = field;
            ElementItem  = item;
        }
        public ElementCell(ElementField field, ElementItem item)
            : this()
        {
            Validations.ArgumentNullOrDefault(field, "field");
            Validations.ArgumentNullOrDefault(item, "item");

            ElementField = field;
            ElementItem = item;
        }
        public UserElementField(User user, ElementField elementField, decimal rating)
            : this()
        {
            Validations.ArgumentNullOrDefault(user, "user");
            Validations.ArgumentNullOrDefault(elementField, "elementField");

            User = user;
            ElementField = elementField;
            Rating = rating;
        }
        public ElementCell AddCell(ElementField field)
        {
            Validations.ArgumentNullOrDefault(field, "field");

            if (ElementCellSet.Any(item => item.ElementField == field))
                throw new Exception("An element item can't have more than one cell for the same field.");

            var cell = new ElementCell(field, this);
            field.ElementCellSet.Add(cell);
            ElementCellSet.Add(cell);
            return cell;
        }
        public ElementCell AddCell(ElementField field)
        {
            Validations.ArgumentNullOrDefault(field, "field");

            if (ElementCellSet.Any(item => item.ElementField == field))
            {
                throw new Exception("An element item can't have more than one cell for the same field.");
            }

            var cell = new ElementCell(field, this);

            field.ElementCellSet.Add(cell);
            ElementCellSet.Add(cell);
            return(cell);
        }
Beispiel #9
0
        public ElementField AddField(string name, ElementFieldDataType fieldType, bool? useFixedValue = null)
        {
            var sortOrder = Convert.ToByte(ElementFieldSet.Count + 1);
            var field = new ElementField(this, name, fieldType, sortOrder, useFixedValue);

            //return AddField(field);
            //}

            //ElementField AddField(ElementField field)
            //{
            // TODO Validation - Same name?

            ElementFieldSet.Add(field);

            return field;
        }
Beispiel #10
0
        public ElementField AddField(string name, ElementFieldDataType fieldType, bool?useFixedValue = null)
        {
            var sortOrder = Convert.ToByte(ElementFieldSet.Count + 1);
            var field     = new ElementField(this, name, fieldType, sortOrder, useFixedValue);

            //return AddField(field);
            //}

            //ElementField AddField(ElementField field)
            //{
            // TODO Validation - Same name?

            ElementFieldSet.Add(field);

            return(field);
        }