1
I need to insert a "row" instead of a table, as in the image example below:
I will fill out this form and I need to register it in the bank. However, I need it to be registered one line at a time. Ex: (Monday, 08:30, 16:30, 30), dps (Tuesday, 08:30, 16:30, 30).
This is my controller:
public string Register(TimeGrid timeGrid)
{
{
if (timeGrid != null)
{
using (TimeGridContext contextObj = new TimeGridContext())
{
try
{
contextObj.workload.Add(timeGrid);
contextObj.SaveChanges();
return "Registro adicionado com sucesso";
}
catch (Exception ex)
{
throw ex;
}
}
}
else
{
return "Registro inválido";
}
}
}
Model:
public class TimeGrid
{
[Key]
public int Id { get; set; }
public DateTime EntryTime { get; set; }
public DateTime DepartureTime { get; set; }
public int Interval { get; set; }
public string NameDayofWeek { get; set; }
}
Html:
Entree
Exit
Interval
Total
Domingo
<div class="row">
<div class="col"><label>Segunda-feira</label></div>
<input type="hidden" ng-true-value="segunda-feira" />
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.MondayIn" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.MondayOut" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.MondayInterval" /></div>
<div class="col"><input type="text" class="form-control" disabled></div>
</div>
<div class="row">
<div class="col"><label>Terça-feira</label></div>
<input type="hidden" ng-true-value="terca-feira" />
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.TuesdayIn" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.TuesdayOut" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.TuesdayInterval" /></div>
<div class="col"><input type="text" class="form-control" disabled></div>
</div>
<div class="row">
<div class="col"><label>Quarta-feira</label></div>
<input type="hidden" ng-true-value="quarta-feira" />
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.WednesdayIn" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.WednesdayOut" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.WednesdayInterval" /></div>
<div class="col"><input type="text" class="form-control" disabled></div>
</div>
<div class="row">
<div class="col"><label>Quinta-feira</label></div>
<input type="hidden" ng-true-value="quinta-feira" />
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.ThursdayIn" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.ThursdayOut" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.ThursdayInterval" /></div>
<div class="col"><input type="text" class="form-control" disabled></div>
</div>
<div class="row">
<div class="col"><label>Sexta-feira</label></div>
<input type="hidden" ng-true-value="sexta-feira" />
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.FridayIn" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.FridayOut" /></div>
<div class="col"><input type="text" class="form-control" ng-model="vm.timeGrid.FridayInterval" /></div>
<div class="col"><input type="text" class="form-control" disabled></div>
</div>
<div class="row">
<div class="col"><label>Sábado</label></div>
<div class="col"><input type="text" class="form-control" /></div>
<div class="col"><input type="text" class="form-control" /></div>
<div class="col"><input type="text" class="form-control" /></div>
<div class="col"><input type="text" class="form-control" disabled></div>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary" value="Salvar" ng-click="timeGrid(timeGridForm)">
</div>
</form>
Controller:
$scope.timeGrid = function () {
result = $scope;
traineeControlService.timeGrid(result.vm)
.then(function () {
alert("Teste 1");
}, function () {
alert('Erro ao tentar adicionar o livro');
});
}
Service
myApp.service("traineeControlService", function ($http) {
this.timeGrid = function (result) {
console.log(result);
var response = $http({
method: "post",
url: "Register",
data: JSON.stringify(result),
dataType: "json"
});
return response;
}
}
You could explain your problem better?
– Leandro Angelo
Include your Timegrid class structure and View
– Leandro Angelo
So, any ideas?
– user103979
Save click makes a post to
Register(TimeGrid timeGrid)
???– Leandro Angelo
Yes, the post reaches my controller layer.
– user103979
Include action, I want to see the parameters she’s receiving and tbm javascript from
ng-click="timeGrid(timeGridForm)
– Leandro Angelo