示例#1
0
        public async Task <IHttpActionResult> Put(int id, [FromBody] MiscConfigurationModel config)
        {
            if (config == null)
            {
                return(BadRequest("Required data was not supplied."));
            }

            if (!await Exists(id))
            {
                return(NotFound());
            }

            var record = await db.MiscConfigurations.FindAsync(id);

            if (config.Description != null && record.Description != config.Description)
            {
                record.Description = config.Description;
            }

            if (config.Value != null && record.Value != config.Value)
            {
                record.Value = config.Value;
            }

            return(await SaveChanges(record, ActionType.Put));
        }
示例#2
0
        public async Task <IHttpActionResult> Post([FromBody] MiscConfigurationModel record)
        {
            if (record == null)
            {
                return(BadRequest("Required data was not supplied."));
            }

            if (await Exists(record.Description))
            {
                return(Conflict());
            }

            db.MiscConfigurations.Add(record);

            return(await SaveChanges(record, ActionType.Post));
        }