public IHttpActionResult PostProduct(LocationVM location)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            var task = repository.Add(location);
            task.Wait();

            return CreatedAtRoute("DefaultApi", new { id = location.Id }, location);
        }
 private location ParseModel(LocationVM vm) {
     var locModel = new location();
     locModel.id = vm.Id;
     locModel.location_name = vm.LocationName;
     return locModel;
 }
 public async Task Update(LocationVM location) {
     dbCtx.Entry(ParseModel(location)).State = System.Data.Entity.EntityState.Modified;
     await dbCtx.SaveChangesAsync();
 }
 public async Task Add(LocationVM location)
 {
     dbCtx.locations.Add(ParseModel(location));
     await dbCtx.SaveChangesAsync();
 }
        public IHttpActionResult Putproduct(int id, LocationVM location)
        {
            if (!ModelState.IsValid) { return BadRequest(ModelState); }

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

            try
            {
                var task = repository.Update(location);
                task.Wait();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (repository.GetLocation(id) == null)
                {
                    return NotFound();
                }
                else {
                    throw;
                }
            }
            return StatusCode(HttpStatusCode.NoContent);
        }