public Task <AlpApiResponse <LocationDto> > AddNewLocation([FromBody] LocationDto location) { var sessionToken = HttpContext.Request.Headers["sessiontoken"]; if (!_accountService.Authorize(sessionToken, new List <RoleType> { RoleType.Admin })) { return(Task.FromResult(new AlpApiResponse <LocationDto> { Success = false, Message = "Nincs jogosultsága ehhez a művelethez!" })); } return(_locationService.AddNewLocation(location)); }
public async Task <Dictionary <string, object> > AddNewLocation(Location location) { Dictionary <string, object> res = new Dictionary <string, object>(); string username = Request.Headers["username"]; Customer customer = await CustomerService.GetCustomerByUsername(username); bool ret = await Service.AddNewLocation(customer, location); if (ret) { res["status"] = "success"; res["message"] = "添加成功!"; } else { res["status"] = "failed"; res["message"] = "服务器错误, 请稍后再试!"; } return(res); }