public async Task <InsertTransactionOutputModel> InsertTransaction([FromBody] InsertTransactionInputModel input)
        {
            if (!CheckEmpLocation(new CheckEmpLocationInputModel {
                CivilID = input.CivilId, Latitude = input.Lat, Longitude = input.Long
            }).Result.Status)
            {
                return(new InsertTransactionOutputModel
                {
                    Status = false,
                    Message = (input.LanguaugeId == 1) ? "غير مسموح بالبصمه فى هذا الموقع" : "Transaction Not Allowed"
                });
            }
            MobileTransaction mobileTransaction = new MobileTransaction
            {
                CivilId     = input.CivilId,
                Image       = input.ZoomAuditImage,
                Longitude   = input.Long,
                Latitude    = input.Lat,
                TransType   = input.Type,
                SiteId      = input.SiteId,
                SiteName    = input.SiteName,
                EmpCode     = input.EmpCode,
                TransDate   = DateTime.Now,
                TransStatus = true,
                MachineID   = "Mobile"
            };

            try
            {
                await _mobileTransactionRepository.InsertAsync(mobileTransaction);

                return(new InsertTransactionOutputModel
                {
                    Status = true,
                    date = DateTime.Now.ToShortDateString(),
                    Time = DateTime.Now.ToString("hh:mm:ss"),
                    Message = (input.Type == "IN") ? ((input.LanguaugeId == 1) ? "تم اثبات بصمة الحضور" : "Checked in Succesfully") : ((input.LanguaugeId == 1) ? "تم اثبات بصمة الانصراف" : "Checked Out Succesfully")
                });
            }
            catch (Exception ex)
            {
                return(new InsertTransactionOutputModel
                {
                    Status = false,
                    Message = ex.Message
                });
            }
        }
        public async Task <CheckEmpLocationOutputModel> CheckEmpLocation([FromBody] CheckEmpLocationInputModel input)
        {
            var user = await _userManager.Users.Include(x => x.Locations).Where(x => x.CivilId == input.CivilID).FirstOrDefaultAsync();

            var locations = user.Locations.Where(x => x.FromDate.Date <= DateTime.Today & x.ToDate.Date >= DateTime.Today);

            foreach (var item in locations)
            {
                var          location = _locationRepository.GetAll().Where(x => x.Id == item.LocationId).FirstOrDefault();
                List <Point> points   = new List <Point>();
                var          crds     = _locationCredentialRepository.GetAll().Where(x => x.LocationId == item.LocationId);
                foreach (var crd in crds)
                {
                    points.Add(new Point(crd.Latitude, crd.Longitude));
                }
                Point   currentpoint = new Point(input.Latitude, input.Longitude);
                Polygon polygon      = new Polygon(points);
                if (polygon.IsPointInPolygon(currentpoint))
                {
                    return(new CheckEmpLocationOutputModel
                    {
                        Status = true,
                        SiteID = item.LocationId,
                        SiteName = (input.LanguaugeId == 1) ? location.TitleAr : location.TitleEn,
                        FromDate = item.FromDate,
                        EndDate = item.ToDate
                    });
                }
            }
            MobileTransaction transaction = new MobileTransaction
            {
                EmpCode     = user.Code,
                CivilId     = input.CivilID,
                TransType   = "Fail",
                Latitude    = input.Latitude,
                Longitude   = input.Longitude,
                TransStatus = false,
                TransDate   = DateTime.Now
            };

            _mobileTransactionRepository.Insert(transaction);
            return(new CheckEmpLocationOutputModel
            {
                Status = false,
                Message = (input.LanguaugeId == 1) ? "غير مسموح بالبصمة فى هذا المكان" : "Not allowed"
            });
        }