public async Task <bool> DeleteContact(int ApProductionDetailsID)
 {
     using (RTMContext db = new RTMContext())
     {
         DataAccessLayer.EntityModel.ApProductionDetails apProductionDetails =
             db.ApProductionDetails.Where(x => x.ApproductionDetailsId == ApProductionDetailsID).FirstOrDefault();
         if (apProductionDetails != null)
         {
             db.ApProductionDetails.Remove(apProductionDetails);
         }
         return(await db.SaveChangesAsync() >= 1);
     }
 }
        public async Task <bool> SaveContact(APProductionDtailsModel APProductionDtailsModel)
        {
            using (RTMContext db = new RTMContext())
            {
                DataAccessLayer.EntityModel.ApProductionDetails approductionDetails = db.ApProductionDetails.Where
                                                                                          (x => x.ApproductionDetailsId == APProductionDtailsModel.ApproductionDetailsId).FirstOrDefault();
                if (approductionDetails == null)
                {
                    approductionDetails = new ApProductionDetails()
                    {
                        EmailExchangeHeader = APProductionDtailsModel.EmailExchangeHeader,
                        ToEmailAddress      = APProductionDtailsModel.ToEmailAddress,
                        ReceivedFrom        = APProductionDtailsModel.ReceivedFrom,
                        ReceivedTime        = APProductionDtailsModel.ReceivedTime,
                        Subject             = APProductionDtailsModel.Subject,
                        //MessageID=APProductionDtailsModel.MessageID,
                        Market             = APProductionDtailsModel.Market,
                        SubQueue           = APProductionDtailsModel.SubQueue,
                        NoOfAttachment     = APProductionDtailsModel.NoOfAttachment,
                        NoOfTransaction    = APProductionDtailsModel.NoOfTransaction,
                        IndexerComments    = APProductionDtailsModel.IndexerComments,
                        IndexerStartTime   = APProductionDtailsModel.IndexerStartTime,
                        IndexerEndTime     = APProductionDtailsModel.IndexerEndTime,
                        IndexedBy          = APProductionDtailsModel.IndexedBy,
                        AssignedStatus     = APProductionDtailsModel.AssignedStatus,
                        AssignedUser       = APProductionDtailsModel.AssignedUser,
                        AssignedDateTime   = APProductionDtailsModel.AssignedDateTime,
                        AssignedComments   = APProductionDtailsModel.AssignedComments,
                        AssignedBy         = APProductionDtailsModel.AssignedBy,
                        CompletedDateTime  = APProductionDtailsModel.CompletedDateTime,
                        OnHoldStatus       = APProductionDtailsModel.OnHoldStatus,
                        EscalationStatus   = APProductionDtailsModel.EscalationStatus,
                        EscalationComments = APProductionDtailsModel.EscalationComments,
                        Disposition        = APProductionDtailsModel.Disposition,
                        SubDisposition     = APProductionDtailsModel.SubDisposition,
                        Reason             = APProductionDtailsModel.Reason,
                        ProcessorComments  = APProductionDtailsModel.ProcessorComments,
                        ProcessorStartTime = APProductionDtailsModel.ProcessorStartTime,
                        ProcessorEndTime   = APProductionDtailsModel.ProcessorEndTime,
                        // NoOfTransactions_Processor=APProductionDtailsModel.NoOfTransactions_Processor,
                        Status                 = APProductionDtailsModel.Status,
                        EmailType              = APProductionDtailsModel.EmailType,
                        Remarks                = APProductionDtailsModel.Remarks,
                        EmailState             = APProductionDtailsModel.EmailState,
                        ServerReceivedTime     = APProductionDtailsModel.ServerReceivedTime,
                        FirstTouchDate         = APProductionDtailsModel.FirstTouchDate,
                        InvoiceDescription     = APProductionDtailsModel.InvoiceDescription,
                        OnHoldReason           = APProductionDtailsModel.OnHoldReason,
                        OnHoldResolution       = APProductionDtailsModel.OnHoldResolution,
                        WronglyIndexedStatus   = APProductionDtailsModel.WronglyIndexedStatus,
                        WornglyIndexedComments = APProductionDtailsModel.WornglyIndexedComments,
                        //VendorEmailID=APProductionDtailsModel.VendorEmailID,
                        VendorPhoneNo          = APProductionDtailsModel.VendorPhoneNo,
                        UrgentCase             = APProductionDtailsModel.UrgentCase,
                        WronglyIndexedComments = APProductionDtailsModel.WronglyIndexedComments,
                        SourceofStatement      = APProductionDtailsModel.SourceofStatement,
                        InputCategory          = APProductionDtailsModel.InputCategory,
                        EntityName             = APProductionDtailsModel.EntityName,
                        InvoiceCategory        = APProductionDtailsModel.InvoiceCategory,
                    };
                    db.ApProductionDetails.Add(approductionDetails);
                }
                else
                {
                    approductionDetails.EmailExchangeHeader = APProductionDtailsModel.EmailExchangeHeader;
                    approductionDetails.ToEmailAddress      = APProductionDtailsModel.ToEmailAddress;
                    approductionDetails.ReceivedFrom        = APProductionDtailsModel.ReceivedFrom;
                    approductionDetails.ReceivedTime        = APProductionDtailsModel.ReceivedTime;
                    approductionDetails.Subject             = APProductionDtailsModel.Subject;
                    //MessageID=APProductionDtailsModel.MessageID;
                    approductionDetails.Market             = APProductionDtailsModel.Market;
                    approductionDetails.SubQueue           = APProductionDtailsModel.SubQueue;
                    approductionDetails.NoOfAttachment     = APProductionDtailsModel.NoOfAttachment;
                    approductionDetails.NoOfTransaction    = APProductionDtailsModel.NoOfTransaction;
                    approductionDetails.IndexerComments    = APProductionDtailsModel.IndexerComments;
                    approductionDetails.IndexerStartTime   = APProductionDtailsModel.IndexerStartTime;
                    approductionDetails.IndexerEndTime     = APProductionDtailsModel.IndexerEndTime;
                    approductionDetails.IndexedBy          = APProductionDtailsModel.IndexedBy;
                    approductionDetails.AssignedStatus     = APProductionDtailsModel.AssignedStatus;
                    approductionDetails.AssignedUser       = APProductionDtailsModel.AssignedUser;
                    approductionDetails.AssignedDateTime   = APProductionDtailsModel.AssignedDateTime;
                    approductionDetails.AssignedComments   = APProductionDtailsModel.AssignedComments;
                    approductionDetails.AssignedBy         = APProductionDtailsModel.AssignedBy;
                    approductionDetails.CompletedDateTime  = APProductionDtailsModel.CompletedDateTime;
                    approductionDetails.OnHoldStatus       = APProductionDtailsModel.OnHoldStatus;
                    approductionDetails.EscalationStatus   = APProductionDtailsModel.EscalationStatus;
                    approductionDetails.EscalationComments = APProductionDtailsModel.EscalationComments;
                    approductionDetails.Disposition        = APProductionDtailsModel.Disposition;
                    approductionDetails.SubDisposition     = APProductionDtailsModel.SubDisposition;
                    approductionDetails.Reason             = APProductionDtailsModel.Reason;
                    approductionDetails.ProcessorComments  = APProductionDtailsModel.ProcessorComments;
                    approductionDetails.ProcessorStartTime = APProductionDtailsModel.ProcessorStartTime;
                    approductionDetails.ProcessorEndTime   = APProductionDtailsModel.ProcessorEndTime;
                    // NoOfTransactions_Processor=APProductionDtailsModel.NoOfTransactions_Processor;
                    approductionDetails.Status                 = APProductionDtailsModel.Status;
                    approductionDetails.EmailType              = APProductionDtailsModel.EmailType;
                    approductionDetails.Remarks                = APProductionDtailsModel.Remarks;
                    approductionDetails.EmailState             = APProductionDtailsModel.EmailState;
                    approductionDetails.ServerReceivedTime     = APProductionDtailsModel.ServerReceivedTime;
                    approductionDetails.FirstTouchDate         = APProductionDtailsModel.FirstTouchDate;
                    approductionDetails.InvoiceDescription     = APProductionDtailsModel.InvoiceDescription;
                    approductionDetails.OnHoldReason           = APProductionDtailsModel.OnHoldReason;
                    approductionDetails.OnHoldResolution       = APProductionDtailsModel.OnHoldResolution;
                    approductionDetails.WronglyIndexedStatus   = APProductionDtailsModel.WronglyIndexedStatus;
                    approductionDetails.WornglyIndexedComments = APProductionDtailsModel.WornglyIndexedComments;
                    //VendorEmailID=APProductionDtailsModel.VendorEmailID;
                    approductionDetails.VendorPhoneNo          = APProductionDtailsModel.VendorPhoneNo;
                    approductionDetails.UrgentCase             = APProductionDtailsModel.UrgentCase;
                    approductionDetails.WronglyIndexedComments = APProductionDtailsModel.WronglyIndexedComments;
                    approductionDetails.SourceofStatement      = APProductionDtailsModel.SourceofStatement;
                    approductionDetails.InputCategory          = APProductionDtailsModel.InputCategory;
                    approductionDetails.EntityName             = APProductionDtailsModel.EntityName;
                    approductionDetails.InvoiceCategory        = APProductionDtailsModel.InvoiceCategory;
                }

                return(await db.SaveChangesAsync() >= 1);
            }
        }