public dynamic getAttendances(int id)
        {
            var context = new ubietydbEntities();
            context.Configuration.ProxyCreationEnabled = false;

            var abc = (from recordset in context.attRepTemp1
                       where recordset.empid == id
                       select recordset);

            return  abc ;
        }
        public int MarkAttendance(int empid, int shift)
        {
            var context = new ubietydbEntities();

            Attendance attendance = new Attendance();

            attendance.EmpId = empid;
            attendance.MarkFlagId = shift;
            attendance.MarkTime =  TimeZoneInfo.ConvertTime(new DateTime(DateTime.Now.Ticks), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
            context.Attendances.Add(attendance);

            return context.SaveChanges();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var context = new ubietydbEntities();

            Attendance attendance = new Attendance();

            attendance.EmpId = Convert.ToInt16(Request.Form["empid"]);
            attendance.MarkFlagId = 1;
            attendance.MarkTime = TimeZoneInfo.ConvertTime(new DateTime(DateTime.Now.Ticks), TimeZoneInfo.FindSystemTimeZoneById("india standard time"));
            attendance.latitude = Convert.ToDouble(Request.Form["latitude"]);
            attendance.longitude = Convert.ToDouble(Request.Form["longitude"]);
            attendance.markcount = Convert.ToInt16(Request.Form["count"]);

            context.Attendances.Add(attendance);

            if (context.SaveChanges() == 1)
            {

            //HttpClient client = new HttpClient();
            //client.GetAsync(new Uri("http://ubietyapi.azurewebsites.net/api/attendance/punch/1/1/1.2/2.1/-1"));

                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                CloudBlobContainer container = blobClient.GetContainerReference("ubiety");
                container.CreateIfNotExists();

                container.SetPermissions(new BlobContainerPermissions
                {
                    PublicAccess = BlobContainerPublicAccessType.Blob
                });

                DateTime IST = TimeZoneInfo.ConvertTime(new DateTime(DateTime.Now.Ticks), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                String blobName = Request.Form["name"] + "/" + IST.ToString("yyyy") + "/" + IST.ToString("MM") + "/" + IST.ToString("dd") + "/" + Request.Form["count"].ToString();
                CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);

                blockBlob.UploadFromStream(Request.Files[0].InputStream);
            }

            //if (blockBlob.Exists())
            //{
            //    blockBlob = container.GetBlockBlobReference(blobName.Replace("/AM", "/PM"));
            //}
            //if (!blockBlob.Exists())
            //{
            //    blockBlob.Metadata.Add("Latitude", Request.Form["latitude"]);
            //    blockBlob.Metadata.Add("Longitude", Request.Form["longitude"]);
            //    blockBlob.UploadFromStream(Request.Files[0].InputStream);
            //}
        }
        protected string Page_Load(object sender, EventArgs e)
        {
            using (var context = new ubietydbEntities())
            {
                var empQuery = from st in context.Employees
                where st.Email.ToUpper() == Request.Form["email"].ToUpper() && (st.PrimaryMobile == Convert.ToInt64( Request.Form["mobile"]))
                select st;

                if (empQuery.Count() == 1)
                {
                    return "ok";
                }
             }
            return "not ok";
        }
        public int MarkAttendanceWithLatLon(int empid, int shift, Double latitude, Double longitude, Int16 markcount)
        {
            var context = new ubietydbEntities();

            Attendance attendance = new Attendance();

            attendance.EmpId = empid;
            attendance.MarkFlagId = shift;
            attendance.MarkTime = TimeZoneInfo.ConvertTime(new DateTime(DateTime.Now.Ticks), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
            attendance.latitude = latitude;
            attendance.longitude = longitude;
            attendance.markcount = markcount;
            context.Attendances.Add(attendance);

            return context.SaveChanges();
        }
        public IQueryable<EmployeeDTO> GetEmpList()
        {
            var context = new ubietydbEntities();
            context.Configuration.ProxyCreationEnabled = false;

            var dataset2 = (from recordset in context.Employees
                            where recordset.EmpStatus == 1
                            select new EmployeeDTO
                            {
                                EmpId = recordset.EmpId,
                                EmpNum = recordset.EmpNum,
                                EmpName = recordset.EmpName,
                                Email = recordset.Email,
                                MobileNum = recordset.PrimaryMobile,
                                ProfilePicURL = recordset.ProfilePic
                            });
            return dataset2;
        }
        public dynamic GetEmpDetailsOf(int id)
        {
            var context = new ubietydbEntities();
            context.Configuration.ProxyCreationEnabled = false;

            var dataset2 = (from recordset in context.Employees
                            where recordset.EmpId == id
                            select new EmployeeDTO
                            {
                                EmpId = recordset.EmpId,
                                EmpNum = recordset.EmpNum,
                                EmpName = recordset.EmpName,
                                Email = recordset.Email,
                                MobileNum = recordset.PrimaryMobile,
                                ProfilePicURL = recordset.ProfilePic
                            });
            return new { employee = dataset2 };
        }
        public IQueryable<EmployeeDTO> GetEmpDetail(string empnum, string email, Int64 mobileno)
        {
            var context = new ubietydbEntities();

            Random random = new Random();
            int Otp = random.Next(10000, 100000);
            context.Configuration.ProxyCreationEnabled = false;

            var dataset2 = (from recordset in context.Employees
                            where recordset.EmpNum.ToUpper() == empnum.ToUpper() && recordset.Email.ToUpper() == email.ToUpper() && recordset.PrimaryMobile == mobileno
                            select new EmployeeDTO
                            {
                                EmpId = recordset.EmpId,
                                EmpNum = recordset.EmpNum,
                                EmpName = recordset.EmpName,
                                EmpStatus = recordset.EmpStatus,
                                Email = recordset.Email,
                                Otp = Otp
                            });

            return dataset2;
        }
        public dynamic getAttendance(int id)
        {
            var context = new ubietydbEntities();
            context.Configuration.ProxyCreationEnabled = false;

              var abc = (from recordset in context.attendancereports
                                where recordset.empid == id
                                select new AttendanceLineDetail
                                {
                                    inMarkTime = recordset.inmarktime,
                                    inLatitude = recordset.inlatitude,
                                    inLongitude = recordset.inlongitude,
                                    inMarkCount = 1,
                                    empId = recordset.empid,
                                    outMarkTime = recordset.outmarktime,
                                    outLatitude = recordset.outlatitude,
                                    outLongitude = recordset.outlongitude,
                                    outMarkCount = 2
                                });

            return new { attendance = abc };
        }