how to remove courses store in ids in edit post controller

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
ahmedsa
Posts: 9
Joined: Mon 15 Aug 2016 10:17

how to remove courses store in ids in edit post controller

Post by ahmedsa » Sat 08 Oct 2016 12:24

In edit http post i need to remove courses stored in ids variable

note i need remove courses selected not edit


in jquery i store values of removed courses in ids variable

suppose i removed photoshop and flash it will store value of 3,4 in ids variable

below code when click remove it save values of courses removed in variable ids as

array

Code: Select all

$("#tb").on("click", ".r", function () {  
$(this).parent().parent().hide();  
$(this).parent().prev().prev().find("input").addClass("remove");  
var ids = [];  
var i = 0;  
$(".remove").each(function () {  
ids[i] = $(this).val();  
i++;  
});  
for (var k = 0; k < ids.length; k++) {  
alert(ids[k]);  
}  
});  
i show courses per employee from table EmployeeCourse in edit get as following

Code: Select all

var index = 0;  
$.ajax({  
url: "/Employeedata/getcoursesbyempid",  
data:{x:$("#hid").val()},  
success: function (res) {  
$.each(res, function (i, e) {  
$("#tb").append("<tr><td><input type = 'hidden' name='empcourses[" + index + "].CourseId' value='" + e.Id + "'/></td><td>" + e.CourseName + "</td><td><input type='button' value='remove' class='r'/></td></tr>")  
index++;  
});  
}  
})  
public JsonResult getcoursesbyempid(int x)  
{  
db.Configuration.ProxyCreationEnabled = false;  
var data = db.EmployeeCourses.Where(a => a.EmployeeId == x).Join(db.Courses, a => a.CourseId, b => b.Id, (a, b) => new { Id = a.CourseId, CourseName = b.CourseName });  
return Json(data, JsonRequestBehavior.AllowGet);  
}  
my model using as following

Code: Select all

public class Cusomemp2  
{  
    public int Id { get; set; }  
    public string Name { get; set; }  
    public List<EmployeeCourse> empcourses { get; set; }  
}  

when remove courses in edit HTTPPOST what i write here

Code: Select all

[HttpPost]  
public ActionResult Edit(Cusomemp2 custom)  
{  
//what i write to remove courses saved in ids from table EmployeeCourse  
return View();  
}  
see image below for details
Image

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: how to remove courses store in ids in edit post controller

Post by Shalex » Mon 10 Oct 2016 13:51

Please localize the issue and send us a small test project with the corresponding DDL/DML script for reproducing the issue in our environment. Also specify the steps we should follow using it.

In case of >2MB attachment, we recommend either using some file exchange server (send us the corresponding link) or uploading a test project to our FTP server (the credentials will be provided by email request).

ahmedsa
Posts: 9
Joined: Mon 15 Aug 2016 10:17

Re: how to remove courses store in ids in edit post controller

Post by ahmedsa » Fri 14 Oct 2016 13:45

i attached my code and database in the following link
http://www.mediafire.com/file/htc0d7ela ... t_code.rar

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: how to remove courses store in ids in edit post controller

Post by Shalex » Thu 20 Oct 2016 13:42

We have asked for the additional information by email.

Post Reply