public int SaveRejectedProduct(RejectedProduct rejectedProduct) { try { CommandObj.CommandText = "UDSP_SaveRejectedProduct"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@Barcode", rejectedProduct.Barcode); CommandObj.Parameters.AddWithValue("@RejectionReasonId", rejectedProduct.RejectionReasonId); CommandObj.Parameters.AddWithValue("@Notes", rejectedProduct.Notes); CommandObj.Parameters.AddWithValue("@UserId", rejectedProduct.UserId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; ConnectionObj.Open(); CommandObj.ExecuteNonQuery(); var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); return(rowAffected); } catch (Exception exception) { throw new Exception("Could not save rejected product", exception); } finally { CommandObj.Dispose(); CommandObj.Parameters.Clear(); ConnectionObj.Close(); } }
public ActionResult Rejection(RejectedProduct model) { try { var user = (ViewUser)Session["user"]; model.UserId = user.UserId; var result = _iProductionQcManager.SaveRejectedProduct(model); if (result) { TempData["rMessage"] = "Save Successfully!"; ModelState.Clear(); } else { TempData["rMessage"] = " <p style='color:red'>Failed to add !</p>"; } } catch (System.Exception exception) { TempData["rMessage"] = $"<p style='color:red'>Failed to add !" + exception.Message + "</p>"; } finally { var reasons = _iCommonManager.GetAllRejectionReason().ToList(); ViewBag.RejectionReasonId = new SelectList(reasons, "RejectionReasonId", "Reason"); } return(View()); }
public bool SaveRejectedProduct(RejectedProduct rejectedProduct) { var rowAffected = _iProductionQcGateway.SaveRejectedProduct(rejectedProduct); return(rowAffected > 0); }