/// <summary>
        /// Add and Edit Document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditCheckListJobActivityOperator(CheckListJobActivityOperatorCustom data, long userId = 0)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var res = db.CheckListJobActivityOperator.Where(m => m.CheckListJobOperatorId == data.checkListJobOperatorId && m.CheckListJobActivityId == data.checkListJobActivityId).FirstOrDefault();
                if (res == null)
                {
                    try
                    {
                        CheckListJobActivityOperator item = new CheckListJobActivityOperator();
                        item.CheckListJobOperatorId       = data.checkListJobOperatorId;
                        item.OperatorId                   = userId;
                        item.OperatorScannedBarcodeNumber = data.operatorScannedBarcodeNumber;
                        item.BarcodeAssetId               = data.barcodeAssetId;
                        item.OperatorUpoadedDocumentId    = data.operatorUpoadedDocumentId;
                        item.OperatorRemark               = data.operatorRemark;
                        item.CheckListJobActivityId       = data.checkListJobActivityId;
                        item.IsActive        = true;
                        item.IsDeleted       = false;
                        item.IsJobRejected   = false;
                        item.IsAdminApproved = false;
                        item.CreatedBy       = userId;
                        item.CreatedOn       = DateTime.Now;
                        db.CheckListJobActivityOperator.Add(item);
                        db.SaveChanges();
                        obj.response = ResourceResponse.AddedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
                else
                {
                    try
                    {
                        res.OperatorId = userId;
                        res.OperatorScannedBarcodeNumber = data.operatorScannedBarcodeNumber;
                        res.BarcodeAssetId            = data.barcodeAssetId;
                        res.OperatorUpoadedDocumentId = data.operatorUpoadedDocumentId;
                        res.OperatorRemark            = data.operatorRemark;
                        res.CheckListJobActivityId    = data.checkListJobActivityId;
                        res.ActivityEndTime           = DateTime.Now;
                        res.IsAdminApproved           = false;
                        res.IsJobRejected             = false;
                        res.JobRejectedReason         = "";
                        res.ModifiedBy = userId;
                        res.ModifiedOn = DateTime.Now;
                        db.SaveChanges();
                        obj.response = ResourceResponse.UpdatedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex); if (ex.InnerException != null)
                {
                    log.Error(ex.InnerException.ToString());
                }
                obj.response = ResourceResponse.ExceptionMessage;
                obj.isStatus = false;
            }
            return(obj);
        }
        /// <summary>
        /// CheckList Job Activity Operator Start Activity
        /// </summary>
        /// <param name="checkListJobOperatorId"></param>
        /// <param name="checkListJobActivityId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse CheckListJobActivityOperatorStartActivity(int checkListJobOperatorId, int checkListJobActivityId, string barcodeNumber, long userId = 0)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var barcode = db.AssetMaster.Where(m => m.BarcodeAllocatedNumber == barcodeNumber && m.IsDeleted == false).FirstOrDefault();
                if (barcode != null)
                {
                    var checkListActivity = db.CheckListJobActivityMaster.Where(m => m.CheckListJobActivityId == checkListJobActivityId && m.AssetId == barcode.AssetId).FirstOrDefault();
                    if (checkListActivity != null)
                    {
                        var res = db.CheckListJobActivityOperator.Where(m => m.CheckListJobOperatorId == checkListJobOperatorId && m.CheckListJobActivityId == checkListJobActivityId).FirstOrDefault();
                        if (res == null)
                        {
                            try
                            {
                                CheckListJobActivityOperator item = new CheckListJobActivityOperator();
                                item.CheckListJobOperatorId       = checkListJobOperatorId;
                                item.OperatorScannedBarcodeNumber = barcodeNumber;
                                item.OperatorId             = userId;
                                item.CheckListJobActivityId = checkListJobActivityId;
                                item.ActivityStartTime      = DateTime.Now;
                                item.IsActive        = true;
                                item.IsDeleted       = false;
                                item.IsAdminApproved = false;
                                item.CreatedBy       = userId;
                                item.CreatedOn       = DateTime.Now;
                                db.CheckListJobActivityOperator.Add(item);
                                db.SaveChanges();
                                obj.response = ResourceResponse.AddedSucessfully;
                                obj.isStatus = true;
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex); if (ex.InnerException != null)
                                {
                                    log.Error(ex.InnerException.ToString());
                                }
                                obj.response = ResourceResponse.ExceptionMessage;
                                obj.isStatus = false;
                            }
                        }
                        else
                        {
                            try
                            {
                                res.OperatorId = userId;
                                res.OperatorScannedBarcodeNumber = barcodeNumber;
                                res.ActivityStartTime            = DateTime.Now;
                                res.IsAdminApproved = false;
                                res.ModifiedBy      = userId;
                                res.ModifiedOn      = DateTime.Now;
                                db.SaveChanges();
                                obj.response = ResourceResponse.UpdatedSucessfully;
                                obj.isStatus = true;
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex); if (ex.InnerException != null)
                                {
                                    log.Error(ex.InnerException.ToString());
                                }
                                obj.response = ResourceResponse.ExceptionMessage;
                                obj.isStatus = false;
                            }
                        }
                    }
                    else
                    {
                        obj.response = ResourceResponse.BarcodeNotAssignedForThisActivity;
                        obj.isStatus = false;
                    }
                }
                else
                {
                    obj.response = ResourceResponse.BarcodeNotFoundInAssetLibray;
                    obj.isStatus = false;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex); if (ex.InnerException != null)
                {
                    log.Error(ex.InnerException.ToString());
                }
                obj.response = ResourceResponse.ExceptionMessage;
                obj.isStatus = false;
            }
            return(obj);
        }