public async Task <IHttpActionResult> Post(Department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            departmentContext.Departments.Add(department);
            await departmentContext.SaveChangesAsync();

            return(Created(department));
        }
Exemple #2
0
        public async Task <IHttpActionResult> Post(DemoTask task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            taskContext.Tasks.Add(task);
            await taskContext.SaveChangesAsync();

            return(Created(task));
        }
        public async Task <IHttpActionResult> Post(ContactTask contactTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            contactTaskContext.ContactTasks.Add(contactTask);
            await contactTaskContext.SaveChangesAsync();

            return(Created(contactTask));
        }