示例#1
0
        public async Task <IHttpActionResult> PutBaseCustomerType(int id, BaseCustomerType baseCustomerType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != baseCustomerType.Id)
            {
                return(BadRequest());
            }

            db.Entry(baseCustomerType).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BaseCustomerTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public async Task <IHttpActionResult> GetBaseCustomerType(int id)
        {
            BaseCustomerType baseCustomerType = await db.BaseCustomerTypes.FindAsync(id);

            if (baseCustomerType == null)
            {
                return(NotFound());
            }

            return(Ok(baseCustomerType));
        }
示例#3
0
        public async Task <IHttpActionResult> PostBaseCustomerType(BaseCustomerType baseCustomerType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BaseCustomerTypes.Add(baseCustomerType);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = baseCustomerType.Id }, baseCustomerType));
        }
示例#4
0
        public async Task <IHttpActionResult> DeleteBaseCustomerType(int id)
        {
            BaseCustomerType baseCustomerType = await db.BaseCustomerTypes.FindAsync(id);

            if (baseCustomerType == null)
            {
                return(NotFound());
            }

            db.BaseCustomerTypes.Remove(baseCustomerType);
            await db.SaveChangesAsync();

            return(Ok(baseCustomerType));
        }