public async Task <IActionResult> AddAndEditCheckListActivity(CheckListActivityCustom data)
        {
            #region Authorization code
            var    identity = HttpContext.User.Identity as ClaimsIdentity;
            string id       = "";
            string role     = "";
            if (identity != null)
            {
                IEnumerable <Claim> claims = identity.Claims;
                // or
                id   = identity.Claims.Where(m => m.Type == ClaimTypes.Sid).Select(m => m.Value).FirstOrDefault();
                role = identity.Claims.Where(m => m.Type == ClaimTypes.Role).Select(m => m.Value).FirstOrDefault();
            }
            long userId = Convert.ToInt32(id);
            #endregion
            //calling CheckListActivityDAL busines layer
            CommonResponse response = new CommonResponse();
            response = checkListActivityMaster.AddAndEditCheckListActivity(data, userId);

            return(Ok(response));
        }
        /// <summary>
        /// Add and Edit Document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditCheckListActivity(CheckListActivityCustom data, long userId = 0)
        {
            CommonResponse obj            = new CommonResponse();
            CommonFunction commonFunction = new CommonFunction();

            try
            {
                var res = db.CheckListActivityMaster.Where(m => m.ActivityCheckListId == data.checkListActivityId).FirstOrDefault();
                if (res == null)
                {
                    try
                    {
                        var stepCount = commonFunction.ChangeCheckListAndJobStepNumberOfPreviousItem(data.checkListMasterId, data.checkListGroupId, "Activity", "CheckList");

                        CheckListActivityMaster item = new CheckListActivityMaster();
                        item.CheckListMasterId     = data.checkListMasterId;
                        item.CheckListGroupId      = data.checkListGroupId;
                        item.ActivitySubCategoryId = data.activitySubCategoryId;
                        item.CheckListStepNumber   = stepCount + 1;
                        item.Remarks             = data.remarks;
                        item.ActivityDescription = data.activityDescription;
                        item.IsActivityManditory = data.isActivityManditory;
                        item.IsPhotoManditory    = data.isPhotoManditory;
                        item.IsBarCodeManditory  = data.isBarCodeManditory;
                        item.AssetId             = data.assetId;
                        item.IsActive            = true;
                        item.IsDeleted           = false;
                        item.IsAdminApproved     = true;
                        item.CreatedBy           = userId;
                        item.CreatedOn           = DateTime.Now;
                        try
                        {
                            item.ExpectedCompletionTime = data.expectedCompletionTime;
                        }
                        catch (Exception ex)
                        { }
                        db.CheckListActivityMaster.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.CheckListMasterId     = data.checkListMasterId;
                        res.CheckListGroupId      = data.checkListGroupId;
                        res.ActivitySubCategoryId = data.activitySubCategoryId;
                        res.CheckListStepNumber   = data.checkListStepNumber;
                        res.Remarks             = data.remarks;
                        res.ActivityDescription = data.activityDescription;
                        res.IsActivityManditory = data.isActivityManditory;
                        res.IsPhotoManditory    = data.isPhotoManditory;
                        res.IsBarCodeManditory  = data.isBarCodeManditory;
                        res.AssetId             = data.assetId;
                        try
                        {
                            res.ExpectedCompletionTime = data.expectedCompletionTime;
                        }
                        catch (Exception ex)
                        { }
                        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);
        }