public async Task <ResultViewModel> Save(TestVariableViewModel model)
        {
            var result = new ResultViewModel();

            try
            {
                if (model.Id.Equals(0))
                {
                    DbContext.TestVariables.Update(model.ToEntity());
                }
                else
                {
                    DbContext.TestVariables.Add(model.ToEntity());
                }

                await DbContext.SaveChangesAsync();
            }
            catch (Exception ex) {
                result.Message = ex.Message;
            }

            return(await Task.FromResult(result));
        }
 public async Task <ActionResult> Put(int id, [FromBody] TestVariableViewModel model)
 {
     model.Id = id;
     return(Ok(await _service.Save(model)));
 }
 public async Task <ActionResult> Post([FromBody] TestVariableViewModel model)
 {
     return(Ok(await _service.Save(model)));
 }
 public static TestVariable ToEntity(this TestVariableViewModel variableViewModel)
 {
     return(Mapper.Map <TestVariable>(variableViewModel));
 }