/// <summary> /// This function is for searching and deleting a tabletising kneading command item. /// </summary> /// <param name="tabletisingKneadingCommandItem"></param> /// <returns></returns> public ActionResult DeleteKneadingCommand( TabletisingKneadingCommandItem tabletisingKneadingCommandItem) { try { //this wont happend because already validation on view //// It's worth double checking the item whether it is valid for the deletion or not. //if (!await _createTabletisingCommandDomain.IsValidDeleteItem(tabletisingKneadingCommandItem)) //{ // Response.StatusCode = (int) HttpStatusCode.BadRequest; // return Json(new // { // Message = TabletisingResources.MSG11 // }); //} // Call delete function from domain. _createTabletisingCommandDomain.DeleteTabletisingKneadingCommand(tabletisingKneadingCommandItem); return(Json(new { Success = true, Message = TabletisingResources.MSG33 })); } catch (Exception exception) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
/// <summary> /// This function is for deleting kneading command from tabletising list by using specific conditions. /// </summary> /// <param name="tabletisingKneadingCommandItem"></param> /// <returns></returns> public void DeleteTabletisingKneadingCommand( TabletisingKneadingCommandItem tabletisingKneadingCommandItem) { var lotNo = tabletisingKneadingCommandItem.LotNo; // The system will delete the record from “tx56_tbtpdt” //where [f56_kndcmdno] = [Kneading No.] column and [f56_prepdtlotno] = [Lot No.] column on the “List of Kneading Command” table on the Screen 1. _unitOfWork.TabletProductRepository.Delete(x => x.F56_KndCmdNo.Trim().Equals(tabletisingKneadingCommandItem.KneadingNo.Trim()) && x.F56_PrePdtLotNo.Trim().Equals(lotNo.Trim())); // The system will also delete the record from “tx41_tbtcmd” //where [f41_kndcmdno] = [Kneading No.] column and [f41_prepdtlotno] = [Lot No.] column on the “List of Kneading Command” table on the Screen 1. _unitOfWork.TabletCommandRepository.Delete( x => x.F41_KndCmdNo.Trim().Equals(tabletisingKneadingCommandItem.KneadingNo.Trim()) && x.F41_PrePdtLotNo.Trim().Equals(lotNo.Trim())); // Find the item in TX42_KndCmd which will be updated in the system. var kneadingCommands = _unitOfWork.KneadingCommandRepository.GetAll(); kneadingCommands = kneadingCommands.Where( x => x.F42_KndCmdNo.Trim().Equals(tabletisingKneadingCommandItem.KneadingNo.Trim()) && x.F42_PrePdtLotNo.Trim().Equals(lotNo.Trim())); foreach (var kneadingCommand in kneadingCommands) { kneadingCommand.F42_Status = Constants.F42_Status.TX42_Sts_Stored; kneadingCommand.F42_KndCmdNo = tabletisingKneadingCommandItem.KneadingNo; } _unitOfWork.Commit(); }
/// <summary> /// Check whether the tabletising command is valid for deletion or not. /// </summary> /// <param name="tabletisingKneadingCommandItem"></param> /// <returns></returns> public async Task <ActionResult> IsDeleteItemValid(TabletisingKneadingCommandItem tabletisingKneadingCommandItem) { bool results = await _createTabletisingCommandDomain.IsValidDeleteItem(tabletisingKneadingCommandItem); // The deleted item is valid. return(Json(results, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Check whether the item is valid for delete or not. /// </summary> /// <param name="tabletisingKneadingCommandItem"></param> /// <returns></returns> public async Task <bool> IsValidDeleteItem(TabletisingKneadingCommandItem tabletisingKneadingCommandItem) { // If (the selected [Kneading No.] is not equal to // [F41_KndCmdNo] column on table “tx41_tbtcmd”) // or (the selected [Kneading No.] is equal to [F41_KndCmdNo] column on table “tx41_tbtcmd” // and [F41_Status] is not “3” (Not Tablet)), the system will show message as MSG 11. var tabletCommands = _unitOfWork.TabletCommandRepository.GetMany( x => x.F41_KndCmdNo.Equals(tabletisingKneadingCommandItem.KneadingNo)); if (!(await tabletCommands.AnyAsync())) { return(false); } tabletCommands = tabletCommands.Where( x => !x.F41_Status.Equals(Constants.F41_Status.NotTablet)); return(!(await tabletCommands.AnyAsync())); }