concurrent user registration in laravel to mongodb - mongodb

Controller code
$profileDetailsobj = new \stdClass();$profile = [];
// dd($workshop);
if ($workshop->isPublish == 1 && $course_id) {
// dd("as");
$profile['profileId'] = uniqid().$request->input('first_name').time();
$profile['courseId']=$course_id;
$profile['name'] = $request->input('salutation')." ".$request->input('first_name')." ".$request->input('last_name');
$profileDetailsobj->profileDetails[] = $profile;
$workshop->registeredProfiles = $profileDetailsobj;
$workshop->save();
}
This is my code I want to register multiple user entry to mongodb now its only adding only one entry. How to make as multiple ?

Related

Dynamic NAV 2018 Web Service: Creating Sales Order Lines gets error "Standard Code Text does not exist...."

In Dynamic NAV 2018, I exposed page Sales Order (id 36) as web service, I'm following some guides to create Sales Order Header and Sales Order Lines, the Header can be created successfully, but the Sales Lines always get error "Standard Code Text does not exist..."
SOWS.Sales_Order_VS_Service testcreateSO = new SOWS.Sales_Order_VS_Service();
testcreateSO.UseDefaultCredentials = true;
SOWS.Sales_Order_VS SOEntity = new SOWS.Sales_Order_VS();
testcreateSO.Create(ref SOEntity);
SOEntity.Sell_to_Customer_No = "44094";
SOEntity.Store_No = "S9003";
SOEntity.Location_Code = "S9003";
testcreateSO.Update(ref SOEntity);
SOEntity.SalesLines = new SOWS.Sales_Order_Line[1];
SOEntity.SalesLines[0] = new SOWS.Sales_Order_Line();
testcreateSO.Update(ref SOEntity);
SOEntity.SalesLines[0].Type = SOWS.Type.Item;
SOEntity.SalesLines[0].TypeSpecified = true;
SOEntity.SalesLines[0].No = "208122";
SOEntity.SalesLines[0].Quantity = 1;
testcreateSO.Update(ref SOEntity);
System.Web.Services.Protocols.SoapException: 'The Standard Text does not exist. Identification fields and values: Code='208122''
Checking in table Sales Lines, a record of new order has been created but Type = 0 (means blank)
Document No_ Line No_ Sell-to Customer No_ Type No_ Location Code Document Type
SO210600017 10000 0 1
Please help
Solution
Instead of using only singe page Sales Order as web service, can expose page Sales Order Line as another web service, so full code as below:
SOWS.Sales_Order_VS_Service testcreateSO = new SOWS.Sales_Order_VS_Service();
testcreateSO.UseDefaultCredentials = true;
SOWS.Sales_Order_VS SOEntity = new SOWS.Sales_Order_VS();
testcreateSO.Create(ref SOEntity);
SOEntity.Sell_to_Customer_No = "44094";
SOEntity.Store_No = "S9003";
SOEntity.Location_Code = "S9003";
testcreateSO.Update(ref SOEntity);
//Using Sales Order Line page as web service from here
SOLinesWS.salesDocumentLines_Service saleslinesSV = new SOLinesWS.salesDocumentLines_Service
{
UseDefaultCredentials = true
};
SOLinesWS.salesDocumentLines saleslines = new SOLinesWS.salesDocumentLines();
saleslines.documentType = SOLinesWS.documentType.Order;
saleslines.documentTypeSpecified = true;
saleslines.documentNumber = SOEntity.No;
saleslines.type = SOLinesWS.type.Item;
saleslines.typeSpecified = true;
saleslines.number = "208122";
saleslines.quantity = 1;
saleslines.quantitySpecified = true;
saleslinesSV.Create(ref saleslines);

Access data in Core Data using relationships and predicate

I am using Core data to store two databases that contain a relationships.
There is a logbook database and a IFRApproaches database.
A logbook entry can have multiple approaches.
An approach can only be linked to one logbook entry.
Attached is screenshots of my data model and relationships.
When the "submit" button is pressed this is the code to save the entry to the logbook, and the approaches as well.. I need the approaches (how ever many) associated with a singular entry. My question is How I can use a predicate to query the database at a later time for all the approaches associated with a various entry.
lazy var newEntry = Logbook(context: LoadData.shared.context)
if errorCount == 0 {
if modifyEntry == false {
if entryHolding.date == nil {
newEntry.date = Date()
} else {
newEntry.date = entryHolding.date
}
newEntry.aircraftID = entryHolding.aircraftID
newEntry.aircraftSelect = LoadData.shared.aircraftArray[aircraftArrayIndexPath!.row]
newEntry.categoryAndClass = newEntry.aircraftSelect?.categoryAndClass
newEntry.typeCode = entryHolding.typeCode
newEntry.from = entryHolding.from
newEntry.to = entryHolding.to
newEntry.route = entryHolding.route
newEntry.totalTime = entryHolding.totalTime
newEntry.pic = entryHolding.PIC
newEntry.sic = entryHolding.SIC
newEntry.solo = entryHolding.solo
newEntry.dual = entryHolding.dual
newEntry.crossCountry = entryHolding.crossCountry
newEntry.night = entryHolding.night
newEntry.simInstrument = entryHolding.simInstrument
newEntry.actualInstrument = entryHolding.actualInstrument
newEntry.hold = Int16(entryHolding.hold)
newEntry.dayLanding = Int16(entryHolding.dayLanding)
newEntry.nightLanding = Int16(entryHolding.nightLanding)
newEntry.bfr = entryHolding.BFR
newEntry.checkride = entryHolding.checkRide
newEntry.ipc = entryHolding.IPC
newEntry.comments = entryHolding.comments
for i in 0..<approach.count {
var newApproach = IFRApproaches(context: LoadData.shared.context)
newApproach.airport = approach[i].airportID
newApproach.typeOfApproach = approach[i].type
newApproach.runway = approach[i].runwayNum
//newApproach.entry = newEntry
newEntry.addToApproaches(newApproach)
LoadData.shared.approachArray.append(newApproach)
}
LoadData.shared.entryArray.append(newEntry)
LoadData.shared.saveData()

EF6 update not actually updating the table record?

I'm having to write a app that effectively copies data from one databaseA.table to databaseB.table but there are a few fields in databaseB that aren't in databaseA.
I've come up with basic code below. The insert works and the update doesn't trow an error, however, the update doesn't actually update any records.
I've confirmed that the bcEmployee object in the update has the new values from databaseA like it should. The employee object is the record from databaseA.
Am I missing something to make this update?
BC_employee bcEmployee = new BC_employee();
bcEmployee.emp_id = employee.emp_id;
bcEmployee.emp_firstname = employee.emp_firstname;
bcEmployee.emp_lastname = employee.emp_lastname;
using (BCcontext ctx = new BCcontext())
{
var existBCemployee = ctx.employee.Find(employee.emp_id);
if (existBCemployee == null) //Insert
{
//Set default values that aren't in the original database
bcEmployee.emp_paystat = null;
bcEmployee.password = null;
bcEmployee.enroll_date = null;
ctx.employee.Add(bcEmployee);
}
else
{
ctx.Entry(existBCemployee).CurrentValues.SetValues(bcEmployee);
}
ctx.SaveChanges();
}

typo3 formhandler error tx_formhandler_log

I tried to implement a new form which creates a tt_addressrecord. But everytime when I submit the form it shows an error that the table tx_formhandler_log does not exist. But I use the standart ts. Here my ts for my form:
plugin.Tx_Formhandler.settings.predef.newsletter {
disableWrapInBaseClass = 1
# Common configuration
debug = 1
name = Newsletter
addErrorAnchors = 1
1.templateFile = TEXT
1.templateFile.value = typo3conf/templates/main/plugins/formhandler/newsletter.form.html
langFile.1 = typo3conf/templates/main/plugins/formhandler/locallang.xml
formValuesPrefix = notifiers
disableWrapInBaseClass = 1
isErrorMarker.default = error
isErrorMarker {
global = error
}
errorListTemplate {
totalWrap >
singleWrap = <p> | </p>
}
finishers {
1.class = Tx_Finisher_DB
1.config {
table = tt_address
key = uid
fields {
email.mapping = email
email.ifIsEmpty = 1
pid.ifIsEmpty = 109
hidden.ifIsEmpty = 1
module_sys_dmail_html.ifIsEmpty = 1
}
}
2.class = Tx_Formhandler_Finisher_Mail
2.config {
checkBinaryCrLf = message
admin {
templateFile = TEXT
templateFile.value = typo3conf/templates/main/plugins/formhandler/newsletter.email.admin.html
sender_email = email
to_email = {newsletter.mail.address.admin}
replyto_email = email
replyto_name = email
subject = TEXT
subject.value = {newsletter.subject.admin}
}
}
3.class = Finisher_Redirect
3.config {
redirectPage = 1
additionalParams {
success = 1
}
}
}
}
A Database Compare could be helpful for your issue:
Go to the Install Tool -> Important Actions and click on Database Compare. This compares your current database to the configuration files and you can automatically fix missing tables or fields.
In older TYPO3 versions (< 6.2) you'll find this in menu item Database Analyser in the Install Tool.

MVC - Updating multiple records to database using EF

I am new to MVC. I am getting error while updating multiple records to database using EF.
I want to create a group and add members in it.
I created to list
boxes. I have loaded all members in left box.
First time, I created the Group and added members from first box to second box, and saved
the form. All data saved successfully.
While I come to edit the group, I want to add/remove some members from the group, I got
error.
I used the following code for edit mode.
if (!string.IsNullOrEmpty(groupView.GroupName) && groupView.MemberIDs.Count > 0)
{
Groups group = new Groups();
List<GroupMembers> existingMembers = null;
if (groupView.GroupID > 0)
{
group.GroupID = groupView.GroupID;
//db.Entry(group).State = EntityState.Modified;
existingMembers = db.GroupMembers.ToList();
}
else
{
group.GroupID = groupView.GroupID;
group.GroupName = groupView.GroupName;
group.IsActive = true;
db.Groups.Add(group);
}
GroupMembers groupMembers, member;
foreach (short memberId in groupView.MemberIDs)
{
groupMembers = new GroupMembers();
if (groupView.GroupID > 0)
{
//Check whether the Member already exists in the group
member = existingMembers.Where(gm => gm.GroupID == groupView.GroupID && gm.MemberID == memberId).FirstOrDefault();
if (member != null)
{
groupMembers.GroupMemberID = member.GroupMemberID;
db.Entry(groupMembers).State = EntityState.Modified;
}
else
groupMembers.GroupMemberID = 0;
}
groupMembers.GroupID = group.GroupID;
groupMembers.MemberID = memberId;
groupMembers.IsActive = Convert.ToBoolean(groupView.IsActive);
if (groupMembers.GroupMemberID == 0)
db.GroupMembers.Add(groupMembers);
}
db.SaveChanges();
At runtime I received the following exception:
An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key
If I removed the following code from the above coding, duplicate data inserted in DB.
db.Entry(group).State = EntityState.Modified;
I am new to MVC, EF, as per my knowledge I wrote the above coding. I searched and checked some questions with the error information, but I am not able to understand clearly. So I put my coding. Please guide me to resolve this issue.
Thanks in advance.