public KeyValuePair <int, String> WSID_Delete(WSID model) { var param = new SqlParameter[] { new SqlParameter("@WSIDID", SqlDbType.UniqueIdentifier) { Value = model.WSIDID }, new SqlParameter("@ModifiedBy", SqlDbType.UniqueIdentifier) { Value = model.ModifiedBy }, new SqlParameter("@RetVal", SqlDbType.Int) { Direction = ParameterDirection.Output }, new SqlParameter("@Message", SqlDbType.NVarChar, 100) { Direction = ParameterDirection.Output } }; int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[WSID_Delete] @WSIDID, @ModifiedBy, @RetVal out, @Message out", param); int retVal = (int)param[2].Value; string valueRes = param[3].Value.ToString(); return(new KeyValuePair <int, string>(retVal, valueRes)); }
public ActionResult formSubmit(WSID model, string actionType) { List <string> errorMessage = new List <string>(); string successMessage = Resources.NotifResource.RequestSuccess; SessionForSP sessionParam = new SessionForSP(); sessionParam.OrganizationID = new Guid(Session["OrganizationID"].ToString()); if (ModelState.IsValid) { KeyValuePair <int, string> results = new KeyValuePair <int, string>(1, ""); model.ModifiedBy = new Guid(Session["CurrentUserID"].ToString()); if (actionType == "Create") { model.WSIDID = Guid.NewGuid(); results = db.WSID_Insert(model, sessionParam); } else if (actionType == "Edit") { results = db.WSID_Update(model); } else if (actionType == "ChangeStatus") { results = db.WSID_ChangeStatus(model); } else if (actionType == "Delete") { results = db.WSID_Delete(model); } if (results.Key == 0 || results.Key == 16 || results.Key == 6) { UrlHelper u = new UrlHelper(this.ControllerContext.RequestContext); string url = u.Action("Edit", "WSID", new { id = model.WSIDID, success = successMessage }); string urlNew = u.Action("Create", "WSID"); var jsonData = new { flag = true, Message = url, urlNew = urlNew }; return(Json(jsonData)); } else { var jsonData = new { flag = false, Message = results.Value.ToString() }; return(Json(jsonData)); } } else { foreach (var key in ModelState.Keys) { var error = ModelState[key].Errors.FirstOrDefault(); if (error != null) { errorMessage.Add(error.ErrorMessage); } } var jsonData = new { flag = false, Message = errorMessage.First() }; return(Json(jsonData)); } }
public ActionResult Delete(WSID model) { return(formSubmit(model, "Delete")); }
public ActionResult ChangeStatus(WSID model) { return(formSubmit(model, "ChangeStatus")); }
public ActionResult Edit(WSID model) { return(formSubmit(model, "Edit")); }
public ActionResult Edit(Guid id) { WSID model = db.wsid.Find(id); return(View(model)); }
public ActionResult Create(WSID model) { return(formSubmit(model, "Create")); }
public ActionResult Create() { WSID model = new WSID(); return(View(model)); }
public KeyValuePair <int, String> WSID_Update(WSID model) { var param = new SqlParameter[] { new SqlParameter("@WSIDID", SqlDbType.UniqueIdentifier) { Value = model.WSIDID }, new SqlParameter("@ModifiedBy", SqlDbType.UniqueIdentifier) { Value = model.ModifiedBy }, new SqlParameter("@Name", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Name) }, new SqlParameter("@Address", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Address) }, new SqlParameter("@Camera", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Camera) }, new SqlParameter("@City", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.City) }, new SqlParameter("@Coordinator", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Coordinator) }, new SqlParameter("@DescKU", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.DescKU) }, new SqlParameter("@DescKW", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.DescKW) }, new SqlParameter("@InstallDate", SqlDbType.DateTime) { Value = CheckForDbNull(model.InstallDate) }, new SqlParameter("@Island", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Island) }, new SqlParameter("@Location", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Location) }, new SqlParameter("@Lok", SqlDbType.NVarChar, 100) { Value = CheckForDbNull(model.Lok) }, new SqlParameter("@RetVal", SqlDbType.Int) { Direction = ParameterDirection.Output }, new SqlParameter("@Message", SqlDbType.NVarChar, 100) { Direction = ParameterDirection.Output } }; int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[WSID_Update] @WSIDID, @ModifiedBy, @Name, @Address, @Camera, @City, @Coordinator, @DescKU, @DescKW, @InstallDate, @Island, @Location, @Lok, @RetVal out, @Message out", param); int retVal = (int)param[13].Value; string valueRes = param[14].Value.ToString(); return(new KeyValuePair <int, string>(retVal, valueRes)); }