internal bool SubmitActivityAttendance(SubmitActivityAttendanceModal submitActivityAttendanceModal)
        {
            var tableResponse = _dbConnection.GetModelDetails(RawSQL.GetVoidedAttendance(submitActivityAttendanceModal.ActivityDate, submitActivityAttendanceModal.ActivityCode));
            var checkRec      = tableResponse.AsEnumerable().FirstOrDefault();

            if (checkRec != null)
            {
                throw new CustomException("Selected Activity is voided, unable to post attendance");
            }
            return(_dbConnection.SaveActivityAttendance(submitActivityAttendanceModal));
        }
        public bool SaveActivityAttendance(SubmitActivityAttendanceModal submitActivityAttendanceModal)
        {
            int final = 0;

            try
            {
                using (var connection = new OleDbConnection(connString))
                {
                    connection.Open();
                    using (var cmd = new OleDbCommand(@"Insert into Act2018 (Roll_NO, Act_cd, Act_Date) VALUES (@Roll_NO, @Act_cd, @Act_Date)", connection))
                    {
                        cmd.CommandTimeout = 300;
                        Parallel.ForEach(submitActivityAttendanceModal.RollNoList, rollNo =>
                        {
                            lock (lockObj)
                            {
                                cmd.Parameters.Clear();
                                cmd.Parameters.AddRange(new OleDbParameter[]
                                {
                                    new OleDbParameter {
                                        ParameterName = "@Roll_NO", Value = rollNo
                                    },
                                    new OleDbParameter {
                                        ParameterName = "@Act_cd", Value = submitActivityAttendanceModal.ActivityCode
                                    },
                                    new OleDbParameter {
                                        ParameterName = "@Act_Date", Value = submitActivityAttendanceModal.ActivityDate
                                    },
                                });
                                cmd.ExecuteNonQueryAsync();
                            }
                        });
                        //foreach (var rollNo in submitActivityAttendanceModal.RollNoList)
                        //{
                        //    cmd.Parameters.Clear();
                        //    cmd.Parameters.AddRange(new OleDbParameter[]
                        //    {
                        //        new OleDbParameter { ParameterName = "@Roll_NO", Value = rollNo },
                        //        new OleDbParameter { ParameterName = "@Act_cd", Value = submitActivityAttendanceModal.ActivityCode },
                        //        new OleDbParameter { ParameterName = "@Act_Date", Value = submitActivityAttendanceModal.ActivityDate },
                        //    });
                        //    cmd.ExecuteNonQuery();
                        //}
                    }
                    //return Task.FromResult(bool);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"$$$SaveActivityAttend$$$####Error Message ->>>{ex} && {ex.Message}###### + StackTrace {ex.StackTrace}######## + InnerEx{ex.InnerException}#####");
                return(false);
            }
        }
Beispiel #3
0
        public IActionResult DeleteSavedAttendance(SubmitActivityAttendanceModal deleteSavedAttendance)
        {
            var result = new RequestResult <bool>()
            {
                Data    = _attendanceManager.DeleteSavedAttendance(deleteSavedAttendance),
                Message = "Success",
                Success = true
            };

            return(Ok(result));
        }
Beispiel #4
0
        public IActionResult SubmitActivityAttendance(SubmitActivityAttendanceModal submitActivityAttendanceModal)
        {
            var result = new RequestResult <bool>()
            {
                Data    = _attendanceManager.SubmitActivityAttendance(submitActivityAttendanceModal),
                Message = "Success",
                Success = true
            };

            return(Ok(result));
        }
 internal bool DeleteSavedAttendance(SubmitActivityAttendanceModal deleteSavedAttendance)
 {
     if (deleteSavedAttendance.RollNoList.Count > 0)
     {
         _dbConnection.DeleteSavedAttendance(deleteSavedAttendance);
     }
     if (deleteSavedAttendance.Name.Count > 0)
     {
         _dbConnection.DeleteVisitorsSavedAttendance(deleteSavedAttendance);
     }
     return(true);
 }
        internal int DeleteSavedAttendance(SubmitActivityAttendanceModal obj)
        {
            int        final        = 0;
            List <int> validRollNum = obj.RollNoList.Where(s => s != 0).Select(s => s).ToList();

            try
            {
                using (var connection = new OleDbConnection(connString))
                {
                    connection.Open();
                    using (var cmd = new OleDbCommand("DELETE FROM Act2018 WHERE Act_Date = @Act_Date and Roll_NO = @Roll_NO and Act_cd = @Act_cd", connection))
                    {
                        cmd.Connection     = connection;
                        cmd.CommandTimeout = 300;
                        for (int i = 0; i < validRollNum.Count(); i++)
                        {
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add(new OleDbParameter {
                                ParameterName = "@Act_Date", Value = (obj.ActivityDate), OleDbType = OleDbType.Date
                            });
                            cmd.Parameters.Add(new OleDbParameter {
                                ParameterName = "@Roll_No", Value = validRollNum[i], OleDbType = OleDbType.SmallInt
                            });
                            cmd.Parameters.Add(new OleDbParameter {
                                ParameterName = "@Act_cd", Value = obj.ActivityCode, OleDbType = OleDbType.WChar
                            });
                            final += cmd.ExecuteNonQuery();
                        }
                    }
                    return(final);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"ManageActivity####Error Message ->>>{ex} && {ex.Message}###### + StackTrace {ex.StackTrace}######## + InnerEx{ex.InnerException}#####");
                return(0);
            }
        }
        internal int DeleteVisitorsSavedAttendance(SubmitActivityAttendanceModal obj)
        {
            int final = 0;

            try
            {
                using (var connection = new OleDbConnection(connString))
                {
                    connection.Open();
                    using (var cmd = new OleDbCommand("DELETE FROM VisitorOD WHERE Act_Date = @Act_Date and VisitorName = @VisitorName and Act_cd = @Act_cd", connection))
                    {
                        cmd.Connection     = connection;
                        cmd.CommandTimeout = 300;
                        for (int i = 0; i < obj.Name.Count(); i++)
                        {
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add(new OleDbParameter {
                                ParameterName = "@Act_Date", Value = (obj.ActivityDate), OleDbType = OleDbType.Date
                            });
                            cmd.Parameters.Add(new OleDbParameter {
                                ParameterName = "@VisitorName", Value = obj.Name[i], OleDbType = OleDbType.VarChar
                            });
                            cmd.Parameters.Add(new OleDbParameter {
                                ParameterName = "@Act_cd", Value = obj.ActivityCode, OleDbType = OleDbType.WChar
                            });
                            final += cmd.ExecuteNonQuery();
                        }
                    }
                    return(final);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"ManageActivity####Error Message ->>>{ex} && {ex.Message}###### + StackTrace {ex.StackTrace}######## + InnerEx{ex.InnerException}#####");
                return(0);
            }
        }
 public bool DeleteSavedAttendance(SubmitActivityAttendanceModal deleteSavedAttendance)
 {
     return(_attendanceDataAccess.DeleteSavedAttendance(deleteSavedAttendance));
 }
 public bool SubmitActivityAttendance(SubmitActivityAttendanceModal submitActivityAttendanceModal)
 {
     return(_attendanceDataAccess.SubmitActivityAttendance(submitActivityAttendanceModal));
 }