AngularJS render updated record + Laravel backend


Employee.php



```
<div class="col-xs-12">
<h2>Listing Employee</h2>
<hr>
<div class="employeeGrid">  
    <table>
        <tr>
            <th><a href="" ng-click="orderByField='name'; reverseSort = !reverseSort">Name</a></th>
            <th><a href="" ng-click="orderByField='age'; reverseSort = !reverseSort">Age</a></th>
            <th><a href="" ng-click="orderByField='gender'; reverseSort = !reverseSort">Gender</a></th>
            <th><a href="" ng-click="orderByField='company'; reverseSort = !reverseSort">Company</a></th>
            <th>Action</th>
        </tr>
        <tr ng-repeat="person in employee | orderBy:orderByField:reverseSort"">
            <td>{{person.name}}</td>
            <td>{{person.age}}</td>
            <td>{{person.gender}}</td>
            <td>{{person.company}}</td>
            <td>
                 <button class="btn" ng-click="viewEmployee(person.id)"><span class="glyphicon glyphicon-eye-open"></button> 
                 <button class="btn" ng-click="editEmployee(person.id)"><span class="glyphicon glyphicon-pencil"></button> 
                 <button class="btn" ng-click="deleteEmployee(person.id)"><span class="glyphicon glyphicon-trash"></button>
            </td>
        </tr>
    </table>        
</div>
```

EmployeeController.js



```
scope = $scope;

scope.employee = [];

scope.$on('$stateChangeSuccess', function () {
    scope.init();   
});

scope.init = function(){
    $http({
        method: 'GET',
        url: '/api/v1/employee/list'
    }).then(function successCallback(response){
        scope.employee = response.data;
    });
}

scope.editEmployee = function(val){

    empScope = $scope;

    $uibModal.open({
        animation: false,
        templateUrl: '../assets/templates/modal/employee/updateEmployee.php',
        controller: 'UpdateEmployeeController',
        size: '',
        backdrop: 'static',
        resolve: { empId: function () { return val; } }
    }).result.catch(function(res) {       
          if (!(res  'cancel' || res  'escape key press')) {
            throw res;
          }
    });
};
```

UpdateEmployeeController.js



```
scope = $scope;

scope.employee = [];

$http({
       method: 'GET',
       url: '/api/v1/employee/get/' + scope.$resolve.empId
}).then(function successCallback(response){
       scope.employee = response.data;
});

scope.updateEmployee = function(){

       $http({
            method: 'POST',
            url: '/api/v1/employee/update/' + scope.$resolve.empId,
            data: {
                name:scope.employee.name,
                age:scope.employee.age,
                gender:scope.employee.gender,
                company:scope.employee.company
            }
       }).then(function successCallback(response){
            //console.log(response.data);                       
       }, function errorCallback(response) {
            console.log(response.data);
       });

       //scope.$dismiss('cancel');
}
```

EmployeeController.php



```
public function lsAll(){
    $employee = Employee::all();
    return $employee;
}

public function getOne($id){
    $employee = Employee::find($id);
    return $employee;
}

public function update(Request $request, $id){
    $employee = Employee::findOrFail($id);      

    $name=$request->input('name');
    $age=$request->input('age');
    $gender=$request->input('gender');
    $company=$request->input('company');

    $employee->name = $name;
    $employee->age = $age;
    $employee->gender = $gender;
    $employee->company = $company;

    if($employee->save()){ 
        return response()->json(['response' => 'The employee record is updated successful']);
    }else{
        return response()->json(['response' => 'Failed to update the employee record']);
    }
}
```

QUESTION


How do I parse an event from UpdateEmployeeController to EmployeeController during an edit action and render (reload) a specific record with the updated data from database.
It's going to be sheer luck anyone is running that setup so try this. Break the problem down to smaller steps. If a step can't be accomplished then it's too big a step. Break it down further.
Hi, Really hard to work this out from your query but I suspect the answer would be a correlated sub query to find the latest appointment date.



https://www.geeksforgeeks.org/sql-correlated-subqueries/ Hi,  

  

check the following Code  

SQLCopy Code

```
-- Question 1 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E

-- Question 1&2 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites',
CASE WHEN (E.TotalTime/60)>=6 THEN E.TotalTime - (30* ROUND((E.TotalTime/60*6),1))
     ELSE (E.TotalTime/60) END 'TotalWorkHours'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E
```
  

  

For ur Question 2, I am not getting. give some more details about that. if possible send some sample data. if access over lap like (From date is 2013 -04-05 11:55:00PM to 2013-04-05 19:10:00PM)  

then we can't able to fine the time difference. So check the code for Question No 1 and give the feedback.  

  

Regards,  

GVPrabu use promise.allsettled(). the following code works, it's simply going to skip over the rejected promise:
```javascript
function getwikiprofiles(data) {
 const profiles = data.people.map(person => {
 return getjson(wikiurl + person.name);
 });
 return promise.allsettled(profiles);
}
function generatehtml(data) {
 //console.log(data);
 data.foreach(person => {
 if (person.status  'fulfilled') {
 person = person.value;
 const section = document.createelement('section');
 peoplelist.appendchild(section);
 section.innerhtml = 
 ![](%24%7bperson.thumbnail.source%7d)
${person.title}



${person.description}


${person.extract}


;
 }
 });
``` Hey,



You could consider using this API ‘QUSRJOBI’ with format ‘*JOBI0300′.*

It Returns you Job Status, JOBQ details and few other details which you might need. [Here](https://publib.boulder.ibm.com/iseries/v5r1/ic2924/index.htm?info/apis/qusrjobi.htm) You go for full details.

Pradeep. Using [reflection](/questions/tagged/reflection "show questions tagged 'reflection'") and [expression-trees](/questions/tagged/expression-trees "show questions tagged 'expression-trees'") you can provide the parameters and then call `OrderBy` function, Instead of returning `Expression<Func<Task, T>>` and then calling `OrderBy`.


Note that `OrderBy` is an extension method and has implemented in both `System.Linq.Enumarable` and `System.Linq.Queryable` classes. The first one is for [linq-to-objects](/questions/tagged/linq-to-objects "show questions tagged 'linq-to-objects'") and the latter is for [linq-to-entities](/questions/tagged/linq-to-entities "show questions tagged 'linq-to-entities'"). [entity-framework](/questions/tagged/entity-framework "show questions tagged 'entity-framework'") needs the expression tree of the query in order to translate it to SQL commands. So we use the `Queryable` implementation.


It can be done by an extension method(explanations added as comments):



```
public static IOrderedQueryable<TSource> OrderBy<TSource>(
       this IQueryable<TSource> query, string propertyName)
{
    var entityType = typeof(TSource);

    //Create x=>x.PropName
    var propertyInfo = entityType.GetProperty(propertyName);
    ParameterExpression arg = Expression.Parameter(entityType, "x");
    MemberExpression property = Expression.Property(arg, propertyName);
    var selector = Expression.Lambda(property, new ParameterExpression[] { arg });

    //Get System.Linq.Queryable.OrderBy() method.
    var enumarableType = typeof(System.Linq.Queryable);
    var method = enumarableType.GetMethods()
         .Where(m => m.Name == "OrderBy" && m.IsGenericMethodDefinition)
         .Where(m =>
         {
            var parameters = m.GetParameters().ToList();
            //Put more restriction here to ensure selecting the right overload                
            return parameters.Count == 2;//overload that has 2 parameters
         }).Single();
    //The linq's OrderBy<TSource, TKey> has two generic types, which provided here
    MethodInfo genericMethod = method
         .MakeGenericMethod(entityType, propertyInfo.PropertyType);

    /*Call query.OrderBy(selector), with query and selector: x=> x.PropName
      Note that we pass the selector as Expression to the method and we don't compile it.
      By doing so EF can extract "order by" columns and generate SQL for it.*/
    var newQuery = (IOrderedQueryable<TSource>)genericMethod
         .Invoke(genericMethod, new object[] { query, selector });
    return newQuery;
}

```

Now you can call this overload of `OrderBy` like any other overload of it.  

For example:



```
var cheapestItems = _context.Items.OrderBy("Money").Take(10).ToList();

```

Which translates to:



```
SELECT TOP (10)  {coulmn names} FROM  [dbo].[Items] AS [Extent1] 
       ORDER BY [Extent1].[Money] ASC

```

This approach can be used to define all overloads of `OrderBy` and `OrderByDescending` methods to have `string` property selector. A trigger is not what you want.


What you need is a scheduled job.


Take a look at the official documentation on the subject:


[Scheduling Jobs with Oracle Scheduler](http://docs.oracle.com/cd/B28359_01/server.111/b28310/scheduse.htm#i1033533)


Feel free to ask more questions if you find any trouble when creating your scheduled job. if you want each cart item to to have each selected employee,

pass item to select\_emplyee(i) method not index for ex. (click)=“select\_emplyee(item)”.

then in implementation add one more extended property to your cartlist json called employeename.

select\_emplyee(item) {



this.employee\_alert… I'm going to assume that you are getting your routine `copy`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

from a module `File::Copy`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

.


After a quick search in CPAN, I came across a module named [`File::Copy::Vigilant`
  




 (adsbygoogle = window.adsbygoogle || []).push({});](https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=)that seems to suit your needs and successfully test reports from perl 5.6.



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

I also found [`File::Copy::Reliable`
  




 (adsbygoogle = window.adsbygoogle || []).push({});](https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=), but it only has reports up to perl 5.8, although that doesn't prove anything. You might just be a bit of a traveling pioneer as far as module goes .... A few things to try.


1. Use [Variable Tables](http://odetocode.com/Articles/365.aspx) instead -> maybe the import wizard prefers that?
2. Name your return fields.


Try using the following stored proc (untested .. just thinking out loud...)



```
CREATE PROCEDURE dbo.Foo
AS

    SET NOCOUNT ON

    DECLARE @ResultTable TABLE (SomeId INTEGER)

    INSERT INTO @ResultTable
    SELECT DISTINCT Id AS Identity -- Or u can rename this field to anything...
    FROM SomeExistingTableWhichHasAnIdentityField

GO

```

Try that and see if the wizard refreshes, now.


-- 


 Attempt #2 :)


Ok .. when the EF designer/wizard/whatever fails to figure out EXACTLY what my stored proc is suppose to be returning, I usually do the following :-


1. Make sure the stored procedure doesn't exist at all in the EF designer/context, etc. (You have a clean starting point)
2. Open up your stored procedure and `/* /*` comment out *EVERYTHING* after the procedure definition.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    /* 
    .... every thing in here is commented out 
    */
GO

```

Now ...
 3. Add a forced fake return in the stored proc, which (more or less) just *defines* the output structure/fields.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    SELECT 1 AS Id, 1 AS UserId, 1 AS SomeOtherId, 
        CAST('AAA' AS NVARCHAR(350)) AS Name,
        -- etc etc etc..
    /* 
    .... every thing in here is commented out 
    */
GO

```

[and then](http://www.youtube.com/watch?v=K7luMp6lb9M) ...


4. Add this stored proc to your EF designer/wizard/etc... Now the correct fields should be 'determined' by the designer. AWESOME. Yes .. the values are all hardcoded .. but that's ok (so far).
5. Once your happy that EF is now updated right, go back to your stored proc, and remove all hardcoded SELECT (which we did in the above step). Now we remove the comments which we commented out the entire real code. So you should have your original stored proc, back.


... and now EF is updated and doesn't know we've changed the plumbing of your stored proc.


win :)


does this work for ya? [@rbarriuso](/u/rbarriuso), to set script response from an async operation use the method below…

event.setresponse(content, statuscode, contenttype)

so in your case it will be like …

myapi.authentication

.login("mylogin", "mypassword")

.then(function(result) {

console.log("auth correct: ", result);

var c…