I need to get previous value of an entity.
My requirement is like; I have some input fields in an edit page.
1 User can enter some values there and press save button at this time the user should be able to save it.
2 User can enter some values there and press Cancel button at this time the page should be reloaded with whatever values were there before the user start editing the page.
My question is that can entity frame work, help us in getting previous value of an object?
Is self tracking is something related to this?
You mentioned "page" so I guess you are talking about web application. In such case you should simply load entity from the database again because pushing Cancel button will make a new request to your web application. You should use a new context per request so you don't have any previous data or entity to reload - you will run a new query and get last data persisted to database.
What you would want to do is:
myContext.Refresh(RefreshMode.StoreWins, myObject);
This will ask the context to reload the entity removing any changes to the object and replacing the property values from the data store.
Related
I have created a entity called #USER-NAME and have set that as a requirement.
Now, for the first time when the entity is detected in the conversation - say, "I am John" , then the memory is set to John. On subsequent encounter of the same entity with different value - "I am Dave", the memory remains unchanged.
I have seen the edit memory option, which provides 1. reset memory 2. set to a value . For the option 2, it does not provide a way to set to the value of #USER-NAME, instead only provides option to enter static values.
How can I update the memory every time the value of the entity changes ??
EDIT
Hi, I am attaching some screenshots to show what's exactly going wrong.
I have a Entity named '#USER_NAME' that saves the user name in a memory variable .
I make the following conversation -
The JSON payload after the conversation is as follows. This works perfectly-
I update the conversation again by providing a new user name.
This triggers the entity just fine. You can see the entity being detected properly.
However, the memory value remains the same.
What I wanted was the memory variable to replace 'Dev' with 'John'.
Remember that:
memory <> Intent
You can set memory in the message section or update automatically using for example a requirement in this case every time the skill is trigged it will replace the value in the memory ID
EDIT: Because the set memory field expect a JSON you can't use memory as you want, but if you reset that memory ID shomewhere relevant in the chat (in my sample I delete it right after saying Hi XXX) so when the skill is trigged again it will "replace" it with the new value
In the Requirement I set the golden entity #Person to variable "name" and if is missing I ask her name.
Sample Image
the memory is a persistent object so if you want to reset it you need either to have specific conditions within the builder or go through a webhook to have a backend code to reste the memory.
I need some help getting random data from core data using Swift 3, Xcode 8.3.1. I currently have an app that creates a list in tableview using data that is entered by the user.. (user enters a name and takes a picture of that person) The entity "Friend" holds the attributes "name", "image".
The first version of this app was just a name and I would use arc4random to randomly update a label with a name on a modally presented VC on a button click. The names were simply stored in an Array.
This version is including an image so I decided to try my hand at core-data (never used it before) and now I'm stuck at my random select button. Currently the app will store the data fine and then retrieve it and display everyone alphabetically along with their image in a tableview. As a new person is submitted the info gets stored and the tableview updates.
I need to show a randomly selected name and its image, but I don't know how to do this and research has failed me on getting it done.
If there is a better way of storing an image & name instead of core-data I'm open to changing as well. The app stores anywhere from 20-80 different names. It will never be used to store much more than that.
You can fetch your items from the context, which will give you an array of objects. Now you just use your favorite random function to get a random index for this array. And then use an object at that index.
I have a form using a Table of REQUEST Using IDRequest (int), TitleOfRequest
and other Table events which can have multiple events for the same request.
So the Table of events will include :
IDEVENTST,
IDRequest,
IDTypeofEvent,
DateStstrong textart,
DateEnd
Table of TYPEOfEvent : IdTypeOfEvent,TitleOfType
From my view to create a new record, the record will create at the final step, i want to make it in order
1 ) Enter a form with fields TitleOfRequest
And fields where the person can enter : DateStart and DateEnd, TypeOfEvent and a button to add, and load the temporary records in datatable.
My questions is : what is the best way to store this temporary data with MVC ? And refresh it in my view then at least to save in my database.
You could use [TempData] if you want to store data for the next request only.TempData allow us to persisting data for the duration of single subsequent request.
If data should be accessible between multiple requests, then use Session.
[Session] is able to store data much more long time, until user session is not expire.
Here is a good blogpost on this matter:
http://petermcintyre.com/2013/01/27/asp-net-mvc-data-persistence-choices/
My application
UITableView has 200 rows
In edit mode each cell has two actions for eg: passAction and failAction
After editing i want to update the database with either 0 or 1 based on its selection
I am retrieving data from server as json and storing it as object
Which is Best?
a. Requesting the server on each time the action is called.
b. Storing it in the local database and sync on completing all rows.
c. Request the server once on completion and send the whole object as JSON.
Help me in choosing the best option of implementation I can do!
Correct me if I bypassed any rules of SO because this is my first question!
#Dan Beaulieu: No need to send all data to server after edit. First update your database and Just send data which was changed in your database.
So add one field like "sync" in your database table and updated field set sync = 1 during edit and get data from database which was set sync = 1 and send it to server.
So I have a tabbed application. The first tab allows a user to enter information in ~20 fields that describe a NSManagedObject. They are then able to save this into core data, and that works just fine.
The second tab is a TableView of all of the existing submissions. Now when a user clicks on a cell in the TableView, it will open up the first tab and repopulate all of the fields that were originally saved into core data. When the user clicks save again, I want the existing submission in core data to be updated, instead of a new insertion into core data.
I have found a lot of information saying that I should make a fetch request and then update it like that. But that seems redundant to me because I already have the object that was saved passed to the first tab/ViewController.
If you could point me to some code that would help my situation or describe a way you might accomplish this scenario, I would greatly appreciate it!
Since you have a reference to the NSManagedObject in the first tab, you can update its properties to the new values when the user saves. You can then save the changes to your NSManagedObject (let's call it myObject for simplicity) by calling [[myObject managedObjectContext] save:&error] where error is an NSError *.