public SAP_Vendor.Data.SAP_VendorCreation AddVendorCreation(string initiatorId, string initiatorName)
 {
     try
     {
         SAP_VendorCreation objMain = SAP_VendorCreation.Where(d => d.InitiatorId == initiatorId && d.Status == 60).FirstOrDefault();
         if (objMain != null)
         {
             return(objMain);
         }
         else
         {
             string requestId = Guid.NewGuid().ToString();
             objMain               = new SAP_VendorCreation();
             objMain.RequestType   = "New";
             objMain.InitiatorId   = initiatorId;
             objMain.InitiatorName = initiatorName;
             objMain.Status        = 60;
             objMain.IncidentNo    = 0;
             objMain.RequestId     = requestId;
             this.Entry <SAP_VendorCreation>(objMain).State = EntityState.Added;
             var count = this.SaveChanges();
             return(objMain);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public SAP_VendorCreation ClearVendorCreation(string requestId, string initiatorId, string initiatorName)
        {
            try
            {
                SAP_VendorCreation objMain = SAP_VendorCreation.Where(d => d.RequestId == requestId && d.Status == 60).FirstOrDefault();
                if (objMain != null)
                {
                    this.Entry(objMain).State = EntityState.Detached;
                    objMain               = new SAP_VendorCreation();
                    objMain.RequestType   = "New";
                    objMain.RequestId     = requestId;
                    objMain.InitiatorId   = initiatorId;
                    objMain.InitiatorName = initiatorName;
                    objMain.Status        = 60;
                    objMain.IncidentNo    = 0;

                    this.SAP_VendorCreation.Attach(objMain);
                    this.Entry(objMain).State = EntityState.Modified;
                    this.SAP_VendorAttachment.Where(d => d.RequestId == requestId).ToList().RemoveAll(d => d.RequestId == requestId);
                    this.SaveChanges();
                    return(objMain);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public SAP_VendorCreation GetVendorCreation(string requestId)
 {
     return(SAP_VendorCreation.Where(d => d.RequestId == requestId).FirstOrDefault());
 }