public ActionResult Create(IFormCollection collection, CountLog countLog)
        {
            try
            {
                // Getting values by key
                string eventName = collection["selectedEvent"];
                int    birdID    = Convert.ToInt32(collection["createdLog.BirdID"]);

                // Creating an object to POST
                CountLog count = new CountLog
                {
                    BirdID      = birdID,
                    UserID      = this.User.FindFirstValue(ClaimTypes.NameIdentifier),
                    EventID     = _eventService.GetEventIdByEventName(eventName),
                    DateOfCount = DateTime.Now,
                    Comment     = collection["createdLog.Comment"]
                };

                _countLogService.Post(count);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(View());
            }
        }
        public void Post(CountLog countLog)
        {
            using (SqlConnection con = new SqlConnection(_connectionstring))
            {
                try
                {
                    string sql = "INSERT INTO CountLogs(birdID, applicationUserId, eventID, dateOfCount, comment)";
                    sql += "VALUES(@birdID, @applicationUserId, @eventID, @dateOfCount, @comment)";

                    SqlCommand cmd = new SqlCommand(sql, con);

                    cmd.Parameters.AddWithValue("@birdID", countLog.BirdID);
                    cmd.Parameters.AddWithValue("@applicationUserId", countLog.UserID);
                    cmd.Parameters.AddWithValue("@eventID", countLog.EventID);
                    cmd.Parameters.AddWithValue("@dateOfCount", countLog.DateOfCount);
                    cmd.Parameters.AddWithValue("@comment", countLog.Comment);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.Close();
                }
            }
        }
 public void Post(CountLog countLog)
 {
     _countLogRepo.Post(countLog);
 }