public JsonResult UpdateProspective(string Username, string[] listids) { string str = ""; try { var result = string.Join(",", listids); var UserPros = context.UserProspectingLists.Where(x => x.UserId == Username); if (UserPros.Count() == 0) { context.SpInsertUserPRos(Username, result); context.SaveChanges(); str = "Record Saved"; } else { context.SpUpdateUserPRos(Username, result); context.SaveChanges(); str = "Record Inserted"; } } catch (Exception ex) { cm.ErrorExceptionLogingByService(ex.ToString(), "ManageUser" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "UpdateProspective", "NA", "NA", "NA", "WEB"); str = "Error"; } return(Json(str, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete_Prospective(string listid) { string msg = ""; try { if (listid != "") { var data = context.UserProspectingLists.Where(x => x.listid.Contains(listid)).ToList(); foreach (var i in data) { string[] ids = Array.ConvertAll(i.listid.Split(','), element => element.ToString()); if (ids.Contains(listid)) { ids = ids.Where(val => val != listid).ToArray(); if (ids.Count() > 0) { string idString = String.Join(",", ids); context.SpUpdateUserPRos(@i.UserId, idString); context.SaveChanges(); } else { context.Spdeletedatauserprospecting(@i.Id); context.SaveChanges(); } } } context.SpdeleteProspect(Convert.ToInt32(listid)); context.SaveChanges(); msg = "Record Deleted"; TempData["Message"] = msg; } } catch (Exception ex) { cm.ErrorExceptionLogingByService(ex.ToString(), "ProspectListsClient" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "Save_Role", "NA", "NA", "NA", "WEB"); msg = "Error Occured"; TempData["Message"] = msg; } return(RedirectToAction("Index")); }