Beispiel #1
0
        public async System.Threading.Tasks.Task <ActionResult> Delete(Guid id)
        {
            {
                bool isDeleted = true;
                Guid id1       = new Guid();
                try
                {
                    //Creating object of RawMaterialBL
                    RawMaterialOrderBL rawMaterialorderBL = new RawMaterialOrderBL();
                    (isDeleted, id1) = await rawMaterialorderBL.DeleteRawMaterialOrderBL(id);

                    if (isDeleted)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(Content("Raw Material not deleted"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public static async Task DeleteOrder()
        {
            try
            {
                using (RawMaterialOrderBL RawMaterialorderBL = new RawMaterialOrderBL())
                {
                    //Read Sl.No
                    Write("Order #: ");
                    bool isNumberValid = int.TryParse(ReadLine(), out int serial);
                    if (isNumberValid)
                    {
                        serial--;
                        List <RawMaterialOrder> RawMaterialorders = await RawMaterialorderBL.GetAllRawMaterialOrdersBL();

                        if (serial <= RawMaterialorders.Count - 1)
                        {
                            //Confirmation
                            RawMaterialOrder RawMaterialorder = RawMaterialorders[serial];
                            Write("Are you sure? (Y/N): ");
                            string confirmation = ReadLine();

                            if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase))
                            {
                                //Invoke DeleteSupplierBL method to delete
                                bool isDeleted = await RawMaterialorderBL.DeleteRawMaterialOrderBL(RawMaterialorder.RawMaterialOrderID);

                                if (isDeleted)
                                {
                                    WriteLine("Order Deleted");
                                }
                                RawMaterialOrderDetailBL      RawMaterialorderDetailBL = new RawMaterialOrderDetailBL();
                                List <RawMaterialOrderDetail> detailsList = await RawMaterialorderDetailBL.GetAllRawMaterialOrderDetailsBL();

                                foreach (RawMaterialOrderDetail item in detailsList)
                                {
                                    if (item.RawMaterialOrderID == RawMaterialorder.RawMaterialOrderID)
                                    {
                                        await RawMaterialorderDetailBL.DeleteRawMaterialOrderDetailBL(item.RawMaterialOrderDetailID);
                                    }
                                }
                            }
                        }
                        else
                        {
                            WriteLine($"Invalid Order #.\nPlease enter a number between 1 to {RawMaterialorders.Count}");
                        }
                    }
                    else
                    {
                        WriteLine($"Invalid number.");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }