Hi,
I'm not sure why I'm not able to add another post action in WebApi AccountController. I got this error when I try to access the action
Multiple actions were found that match the request: Authenticate on type Nascence.BodynitsPortal.WebApi.Controllers.AccountController AuthenticateCardNo on type Nascence.BodynitsPortal.WebApi.Controllers.AccountController
Below is my action, one fore normal login, and another with card. Any advice on which part that I do wrong ? Thankss Before. :D
[HttpPost]
public async Task<AjaxResponse> Authenticate(LoginModel loginModel)
{
CheckModelState();
var loginResult = await GetLoginResultAsync(
loginModel.UsernameOrEmailAddress,
loginModel.Password,
loginModel.TenancyName
);
var ticket = new AuthenticationTicket(loginResult.Identity, new AuthenticationProperties());
var currentUtc = new SystemClock().UtcNow;
ticket.Properties.IssuedUtc = currentUtc;
ticket.Properties.ExpiresUtc = currentUtc.Add(TimeSpan.FromMinutes(30));
return new AjaxResponse(OAuthBearerOptions.AccessTokenFormat.Protect(ticket));
}
[HttpPost]
public async Task<AjaxResponse> AuthenticateCardNo(CardLoginModel loginModel)
{
CheckModelState();
var loginResult = await GetCardLoginResultAsync(
loginModel.Facility,
loginModel.CardNo
);
var ticket = new AuthenticationTicket(loginResult.Identity, new AuthenticationProperties());
var currentUtc = new SystemClock().UtcNow;
ticket.Properties.IssuedUtc = currentUtc;
ticket.Properties.ExpiresUtc = currentUtc.Add(TimeSpan.FromMinutes(30));
return new AjaxResponse(OAuthBearerOptions.AccessTokenFormat.Protect(ticket));
}
Hi,
Can I get authenticated token with only just passing username and hashpassword to check within the identity ? Because we have a requirement that to login using swipe card concept, so I can only passing CardNo to get the username and hashpassword. The current Authenticate method is only can be used with username and password string.
Thanks before :D :D
Hi,
Any advice on how to persist data directly after Repository insert or udpate ? My problem right now is, I need to use LINQ to join with the newly inserted data. But because the data is not persisted to DB until the process is finished so my LINQ query return null for me.
A bit of my code below, so the idea is under 1 process, I insert the 'Style' data, and then use it on the LINQ query on the //insert production schedule part
//insert style
var styles = (from tbInput in input.AsQueryable()
select new { Code = tbInput.StyleCode, Description = tbInput.StyleDescription })
.GroupBy(c => new { c.Code, c.Description })
.Select(rs => new CreateStyleDto
{
Code = rs.FirstOrDefault().Code,
Description = rs.FirstOrDefault().Description,
}).ToList();
foreach (CreateStyleDto dto in styles)
{
CreateOrUpdateStyle(dto);
}
//insert production schedule
var productionschedule = (from tbInput in input.AsEnumerable()
join tbProductionLine in _productionLineRepository.GetAll().AsEnumerable() on tbInput.ProductionLineFRCode equals tbProductionLine.FastReactCode
join tbStyle in _styleRepository.GetAll().AsEnumerable() on tbInput.StyleCode equals tbStyle.Code
select new
{
Facility = tbInput.Facility,
ProductionLineId = tbProductionLine.Id,
StyleId = tbStyle.Id,
StyleCode = tbInput.StyleCode,
StyleDescription = tbInput.StyleDescription,
SAM = tbInput.SAM,
ProductionNo = tbInput.ProductionNo,
ExFactory = tbInput.ExFactory,
NoOfOperators = tbInput.NoOfOperators,
NoOfWorkHours = tbInput.NoOfWorkHours,
RemainingQty = tbInput.RemainingQty,
ActualQty = tbInput.ActualQty,
PlanDate = tbInput.PlanDate,
}).GroupBy(grouper => new
{
grouper.Facility,
grouper.ProductionLineId,
grouper.StyleId,
grouper.SAM,
grouper.ExFactory,
grouper.NoOfOperators,
grouper.NoOfWorkHours,
grouper.PlanDate
}).
Select(rs => new CreateProductionScheduleDto
{
Facility = rs.FirstOrDefault().Facility,
StyleId = rs.FirstOrDefault().StyleId,
ProductionLineId = rs.FirstOrDefault().ProductionLineId,
SAM = rs.FirstOrDefault().SAM,
ExFactory = rs.FirstOrDefault().ExFactory,
InlineDate = new DateTime(),
NoOfOperators = rs.FirstOrDefault().NoOfOperators,
NoOfWorkHours = rs.FirstOrDefault().NoOfWorkHours,
PlanDate = rs.FirstOrDefault().PlanDate,
ActualQty = rs.Sum(c => c.ActualQty),
RemainingQty = rs.Sum(c => c.RemainingQty)
}).ToList();
foreach (CreateProductionScheduleDto dto in productionschedule)
{
dto.InlineDate = GetInlineDate(dto);
ProductionScheduleDto currentDto = CheckExist(dto);
if (currentDto == null)
{
_productionScheduleRepository.Insert(dto.MapTo<ProductionSchedule>());
}
else
{
currentDto.ActualQty = dto.ActualQty;
currentDto.NoOfOperators = dto.NoOfOperators;
currentDto.NoOfWorkHours = dto.NoOfWorkHours;
currentDto.RemainingQty = dto.RemainingQty;
currentDto.SAM = dto.SAM;
currentDto.InlineDate = dto.InlineDate;
_productionScheduleRepository.Update(currentDto.MapTo<ProductionSchedule>());
}
}
Thanks before :D :D
Hi,
Is there a easy way to handle datetime type in ABP without considering timezone? The problem is when we pass a datetime to AppService from JSON, it will include the timezone, as the result when the datetime received in service the value will be different then the initial value (because the server timezone is different than the client timezone so reduction/addition will occur to the datetime).
Thanks before for the great support!! :) :)
Hi,
I try to figure this error, but seems everything is okay but I receive "Your request is invalid", I already check the request payload and my JSON string seems okay, same as my DTO. Can advice me where I did wrong ?
The JSON seems cannot be serialize to CreateShiftDto so it return me "input is null"
Thanks before
Here is my piece of code
Service
public bool Create(CreateShiftDto input)
{
try
{
_shiftRepository.Insert(input.MapTo<Shift>());
return true;
}
catch (Exception ex)
{
Logger.Debug(ex.Message);
throw ex;
}
}
Angular function
function create() {
shiftsService.create(vm.shiftss).success(function (result) {
abp.notify.success("Data is created!");
back();
}).error(function (result) {
abp.notify.error(result);
});
}
this is my object (vm.shiftss)
"[{"seq":5,"code":"5","description":"555","timeStart":"2016-04-12T09:53:36.607Z","timeEnd":"2016-04-12T09:53:36.607Z"}]"
and this is my DTO
[AutoMap(typeof(Shift))]
public class CreateShiftDto : IInputDto
{
public virtual int Seq { get; set; }
public virtual string Code { get; set; }
public virtual string Description { get; set; }
public virtual DateTime TimeStart { get; set; }
public virtual DateTime TimeEnd { get; set; }
}